Swift 5 is now officially released!
Swift 5 is a major milestone in the evolution of the language. Thanks to ABI stability, the Swift runtime is now included in current and future versions of Apple’s platform operating systems: macOS, iOS, tvOS and watchOS. Swift 5 also introduces new capabilities that are building blocks for future versions, including a reimplementation of String, enforcement of exclusive access to memory during runtime, new data types, and support for dynamically callable types.
You can try out some of the new features in this playground put together by Paul Hudson.
Stable ABI and Binary Compatibility
The ABI is now declared stable for Swift 5 on Apple platforms. As a result, the Swift libraries are now incorporated into every macOS, iOS, tvOS, and watchOS release going forward. Your apps will be easier to build and smaller because they won’t have to include those libraries.
See these blog posts for more details:
Standard Library Updates
The standard library in Swift 5 includes the following new features:
- String reimplemented with UTF-8 encoding which can often result in faster code (See the UTF-8 String blog post for more background on this change)
- Improved support for raw text in string literals (See the String Literals blog post for more background on this refinement)
- Result and SIMD vector types added to the Standard Library
- Enhancements to String interpolation, adding more flexibility to construct text from data
- Performance improvements to Dictionary and Set
Swift 5 implements the following Standard Library proposals from the Swift Evolution process:
Additional Language and Compiler Updates
Swift 5 also implements the following language proposals from the Swift Evolution process:
Package Manager Updates
Swift Package Manager includes a number of new features in Swift 5, including dependency mirroring, target-specific build settings, customized deployment targets, and the ability to generate code coverage data. Additionally, the
swift run command now includes the ability to import libraries in a REPL without needing to build an executable.
Swift 5 implements the following Package Manager proposals from the Swift Evolution process:
Migrating to Swift 5
Swift 5 is source compatible with Swift 4, Swift 4.1 and Swift 4.2.
To help with moving to Swift 5 from earlier releases of Swift, Apple’s Xcode 10.2 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 5 ships as part of Xcode 10.2.
A toolchain is also available for download from Swift.org.
Development on Swift 5 was tracked in the swift-5.0-branch on the following repositories on GitHub:
swift-5.0-RELEASE designates the specific revisions in those repositories that make up the final version of Swift 5.
swift-5.0-branch will remain open, but under the same release management process, to accumulate changes for a potential future bug-fix “dot” release.