Swift 4.2 is now officially released! Swift 4.2 builds on the strengths of Swift 4, delivering faster compile times, improving the debugging experience, updating the standard library, and converging on binary compatibility.
Swift 4.2 is a major language release and contains the following language changes and updates that went through the Swift Evolution process:
With the completion of conditional conformance support, Swift 4.2 makes significant progress in implementing the vision of generics in the language. Better support for generics ultimately reduces the amount of boilerplate needed in your code and make more of your code reusable. To learn more about conditional conformance, see more at:
Watch the Swift Generics WWDC 2018 presentation for more details.
Standard Library updates
The standard library in Swift 4.2 includes a number of new features, including improvements to the Hashable protocol as well as a new unified set of randomization functions and protocols.
See more at:
Swift 4.2 brings the language closer towards a stabilized ABI, enabling binary compatibility for future releases of Swift. Visit the ABI Dashboard for more details on the current progress of this effort.
Additional language and compiler updates
Swift 4.2 includes a number of improvements that have a noticable impact on developer experience, including:
- Support for batch mode compilation resulting in faster build times
- Change in calling convention for retain/release cycle to reduce code size and improve runtime performance
- Lazier SIL deserialization with -Onone
- Recursive metadata support
- More compact reflection metadata
- Default arguments are inlined at call sites
- Some long-standing bug fixes, including init declname, switch with multiple case labels per block, inheritance of generic initializers, and more
Swift 4.2 also implements the following language proposals from the Swift Evolution process:
Package Manager Updates
Swift 4.2 introduces new features for the Swift Package Manager:
Support for batch mode. Swift targets will be now compiled using the Swift compiler’s batch mode.
Automatic Xcode project generation. The generate-xcodeproj has a new –watch option to watch the file system and automatically regenerate the Xcode project if needed. This uses the watchman tool to watch the required files.
Improved scheme generation logic. The scheme generation logic is improved and generates schemes as follows:
- One scheme containing all regular and test targets of the root package.
- One scheme per executable target containing the test targets whose dependencies intersect with the dependencies of the executable target.
Swift 4.2 also implements the following Package Manager proposals from the Swift Evolution process:
Migrating to Swift 4.2
Swift 4.2 is source compatible with Swift 4, Swift 4.1 and Swift 3. Swift 4.2 will be the last release to provide source compatibility with Swift 3.
To help with moving to Swift 4.2 from earlier releases of Swift, Apple’s Xcode 10 contains a code migrator that can automatically handle many of the needed source changes. There is also a migration guide available to guide you through many of the changes — especially through the ones that are less mechanical and require more direct scrutiny.
Official binaries for Ubuntu 18.04, Ubuntu 16.04 and Ubuntu 14.04 are
available for download.
For development on Apple’s platforms, Swift 4.2 ships as part of Xcode 10.
A toolchain is also available for download from Swift.org.
Development on Swift 4.2 was tracked in the swift-4.2-branch on the following repositories on GitHub:
swift-4.2-RELEASE designates the specific revisions in those repositories that make up the final version of Swift 4.2.
swift-4.2-branch will remain open, but under the same release management process, to accumulate changes for a potential future bug-fix “dot” release.