Technology
Swift 6.4 unifies building across Linux, macOS, Windows
Key Points
Although Swift serves as Apple's primary language for macOS and iOS application development, the open-source community continues to expand its reach—driving its adoption as a multi-platform language or even a cross-platform one in fields beyond user interface design. Tuesday’s Swift 6.4 release continued that work. Along with the usual assortment of type shortcuts and async adjustments came word that Swift Build is now the default build engine for the Swift Package Manager.
Although Swift serves as Apple's primary language for macOS and iOS application development, the open-source community continues to expand its reach—driving its adoption as a multi-platform language or even a cross-platform one in fields beyond user interface design. Tuesday’s Swift 6.4 release continued that work. Along with the usual assortment of type shortcuts and async adjustments came word that Swift Build is now the default build engine for the Swift Package Manager. Synergies have already ensued! The pairing sets the stage for a faster build process. A developer can write a program in Swift and Swift Build will automatically download and install the required dependencies, testing them for compatibility. It then compiles the code into a CPU-specific binary. The merger also unifies the Swift developer experience regardless of platform. With this integration, a developer can run through the entire build process in their own environment, be it Apple’s Xcode IDE or a beloved command line, and all the steps will be exactly the same for a Linux, macOS, or Windows app. Or the developer can run their builds from VS Code, thanks to a new extension available on the Open VSX Registry. Sweetening the deal, the integrated package comes with a tool to generate an SBOM (Software Bill of Materials) for each app, listing all the dependencies in either the SPDX or CycloneDX format (SE-0509). SBOMs are da bomb when it comes to software auditing and checking for potential security bugs. Swift’s unified toolchain In a way, Swift is following the lead of Rust’s Cargo and Go’s command line, both of which run as unified toolchains, as does Bun for JavaScript. A single integrated workflow can take the place of manually calling one tool after another to schlep some code into production. The Swift Package Manager (SwiftPM), created by Apple in 2015, is a command line automation and dependency management tool. Swift Build itself is a collection of interoperable software development tools that together orchestrate the compilation (using the swiftc compiler), linking and testing of code. SwiftPM can work with any git repository as a source of Swift code, as well as with private repository services such as Bitbucket and JFrog Artifactory. Most notably, SwiftPM works well with the Swift Package Index (SPI), a search service for Swift artifacts created in 2020 and acquired by Apple in June. SPI is currently the de facto repository for many Swifties, housing over 10,400 packages. Many enjoy how the registry tests each dependency for compatibility with each platform and version of Swift. We’d be curious to see if Apple has plans for pulling SPI metadata into SwiftPM. Swift coders not using SwiftPM and Swift Build probably employ Google’s Bazel, Meta’s Buck2, or the venerable CMake to manage their Swiftian assets. Debugging from the source This release streamlines other parts of the build process as well, such as debugging. With Swift 6.4, the default Swift debugger LLDB now has a more storage-efficient way to debug modules, namely by identifying the exact path to the module being used, instead of embedding the entire module into the debugging file, which caused considerable bloat. Now the debugger can follow a pointer and inspect the original module. The release also features interoperability improvements with C++, Java, JavaScript, and even WebAssembly, which gets its own SDK. To start with Swift, go to the Install Swift page. The 6.4 toolchain can be downloaded using the Swiftly command line. ®