Swift 4.0 Released!

Swift 4 is now officially released! Swift 4 builds on the strengths of Swift 3, delivering greater robustness and stability, providing source code compatibility with Swift 3, making improvements to the standard library, and adding features like archival and serialization.

You can watch a quick overview of it by watching the WWDC 2017: What’s New in Swift presentation, and try out some of the new features in this playground put together by Ole Begemann.

Language updates

Swift 4.0 is a major language release and contains the following language changes and updates that went through the Swift Evolution process:

String

Swift 4 includes a faster, easier to use String implementation that retains Unicode correctness and adds support for creating, using and managing substrings.

See more at:

Collection

Swift 4 adds improvements for creating, using and managing Collection types.

See more at:

Archival and serialization

Swift 4 supports archival of struct and enum types and enables type-safe serialization to external formats such as JSON and plist.

See more at: SE-0166 Swift Archival & Serialization

Additional language updates

Swift 4 also implements the following language proposals from the Swift Evolution process:

New compatibility modes

With Swift 4, you may not need to modify your code to use the new version of the compiler. The compiler supports two language modes:

The language mode is specified to the compiler by the -swift-version flag, which is automatically handled by the Swift Package Manager and Xcode.

One advantage of these language modes is that you can start using the new Swift 4 compiler and migrate fully to Swift 4 at your own pace, taking advantage of new Swift 4 features, one module at a time.

For more information about Swift 4 migration and compatibility modes, see Migrating to Swift 4

Package Manager Updates

Swift 4 introduces new workflow features and a more complete API for the Swift Package Manager:

Further, the Swift Package Manager builds on top of package manager tools versioning introduced in Swift 3.1 (SE-0159) which allows a package author to specify the version of Swift required for building a package — which now includes Swift 4.

For more information about enhancements to the Package Manager, see:

Documentation

An updated version of The Swift Programming Language for Swift 4.0 is now available on Swift.org. It is also available for free on Apple’s iBooks store.

Platforms

Linux

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

Apple (Xcode)

For development on Apple’s platforms, Swift 4.0 ships as part of Xcode 9.

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

Sources

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

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

The swift-4.0-branch will remain open, but under the same release management process, to accumulate changes for a potential future bug-fix “dot” release.