Swift 5.1 Released!

Ted Kremenek manages the Languages and Runtimes group at Apple and is a member of the Swift Core Team.

Swift 5.1 is now officially released!

Swift 5.1 builds on the strengths of Swift 5 by extending the stable features of the language to compile time with the introduction of module stability. With module stability it’s now possible to create and share binary frameworks that will work with future releases of Swift. Swift 5.1 also extends the capabilities of the language and the standard library with new features such as property wrappers, opaque result types, key path member lookup, diffing for appropriate collection types, and new APIs for String. Altogether the new features of Swift 5.1 make it easier to design better APIs and reduce the amount of common boilerplate code.

You can learn more about the design considerations for the 5.1 release in episode 79 of the Swift Unwrapped podcast with Doug Gregor. You can also try out some of the new features in this playground put together by Paul Hudson.

Module Stability

Swift 5.1 enables the creation of binary frameworks that can be shared with others leveraging the language’s added support for module stability. Module stability defines a new text-based module interface file that describes the API of a binary framework, allowing it to be compiled with code using different versions of the compiler.

The release also includes features to support library evolution. For more information about this addition to the language, please refer to the Swift Evolution proposal for Library Evolution.

The following blog posts and videos provide more details about the work involving ABI stability, module stability, and library evolution:

Standard Library Updates

The standard library in Swift 5.1 includes the following new features:

Swift 5.1 implements the following Standard Library proposals from the Swift Evolution process:

Additional Language and Compiler Updates

Swift 5.1 includes the following new language features:

Swift 5.1 implements the following language proposals from the Swift Evolution process:

SwiftSyntax Updates

SwiftSyntax has been re-architected with a focus on significantly improving its performance by directly using the parser from the Swift compiler. Further, the performance of syntax tree visitation and related operations has been improved by re-architecting the internal data structures to make them more efficient.

Language Server Protocol

The Swift 5.1 OSS toolchain packages for macOS and Ubuntu include the binaries for SourceKit-LSP, an implementation of the Language Server Protocol (LSP) for Swift and C-based languages.

Migrating to Swift 5.1

Swift 5.1 is source-compatible with Swift 5 and supports compatibility modes for Swift 4.2 and Swift 4/4.1.

To help with moving to the Swift 5 language mode from Swift 4/4.2, Apple’s Xcode 11 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.

Documentation

An updated version of The Swift Programming Language for Swift 5.1 is now available on Swift.org. It is also available for free on the Apple Books store.

Platforms

Linux

Official binaries for Ubuntu 18.04, Ubuntu 16.04 and Ubuntu 14.04 are available for download.

Apple (Xcode)

For development on Apple’s platforms, Swift 5.1 ships as part of Xcode 11.

A toolchain is also available for download from Swift.org.

Sources

Development on Swift 5.1 was tracked in the swift-5.1-branch on the following repositories on GitHub:

The tag swift-5.1-RELEASE designates the specific revisions in those repositories that make up the final version of Swift 5.1.

The swift-5.1-branch will remain open, but under the same release management process, to accumulate changes for the next release.