Swift 5.8 Released!

Alexander Sandberg is an iOS and macOS developer and a member of the Swift Website Workgroup.

Swift 5.8 is now officially released! 🎉 This release includes major additions to the language and standard library, including hasFeature to support piecemeal adoption of upcoming features, an improved developer experience, improvements to tools in the Swift ecosystem including Swift-DocC, Swift Package Manager, and SwiftSyntax, refined Windows support, and more.

Thank you to everyone in the Swift community who made this release possible. Your Swift Forums discussions, bug reports, pull requests, educational content, and other contributions are always appreciated!

For a quick dive into some of what’s new in Swift 5.8, check out this playground put together by Paul Hudson.

The Swift Programming Language book has been updated for Swift 5.8 and is now published with DocC. This is the official Swift guide and a great entry point for those new to Swift. The Swift community also maintains a number of translations.

Language and Standard Library

Swift 5.8 enables you to start incrementally preparing your projects for Swift 6 by using upcoming features. By default, upcoming features are disabled. To enable a feature, pass the compiler flag -enable-upcoming-feature followed by the feature’s identifier.

Feature identifiers can also be used in source code using #if hasFeature(FeatureIdentifier) so that code can still compile with older tools where the upcoming feature is not available.

Swift 5.8 includes upcoming features for the following Swift evolution proposals:

For example, building the following file at /Users/example/Desktop/0274-magic-file.swift in a module called MagicFile with -enable-experimental-feature ConciseMagicFile will opt into the concise format for #file and #filePath described in SE-0274:

fatalError("Something bad happened!")

The above code will produce the following output:

Fatal error: Something bad happened!: file MagicFile/0274-magic-file.swift, line 3

Swift 5.8 also includes conditional attributes to reduce the maintenance cost of libraries that support multiple Swift tools versions. #if checks can now surround attributes on a declaration, and a new hasAttribute(AttributeName) conditional directive can be used to check whether the compiler version has support for the attribute with the name AttributeName in the current language mode:

#if hasAttribute(preconcurrency)
protocol P: Sendable { ... }

Swift 5.8 brings other language and standard library enhancements, including unboxing for any arguments to optional parameters, local wrapped properties in result builders, improved debug printing for key paths, and more.

You can find the complete list of Swift Evolution proposals that were implemented in Swift 5.8 in the Swift Evolution Appendix below.

Developer Experience

Improved Result Builder Implementation

The result builder implementation has been reworked in Swift 5.8 to greatly improve compile-time performance, code completion results, and diagnostics. The Swift 5.8 result builder implementation enforces stricter type inference that matches the semantics in SE-0289: Result Builders, which has an impact on some existing code that relied on invalid type inference.

The new implementation takes advantage of the extended multi-statement closure inference introduced in Swift 5.7 and applies the result builder transformation exactly as specified by the result builder proposal - a source-level transformation which is type-checked like a multi-statement closure. Doing so enables the compiler to take advantage of all the benefits of the improved closure inference for result builder-transformed code, including optimized type-checking performance (especially in invalid code) and improved error messages.

For more details, please refer to the Swift Forums post that outlines the improvements and provides more information about invalid inference scenarios.



As announced in February, The Swift Programming Language book has been converted to Swift-DocC and made open source, and with it came some enhancements to Swift-DocC itself in the form of option directives you can use to change the behavior of your generated documentation. Swift-DocC has also added some new directives to create more dynamic documentation pages, including Grid-based layouts and tab navigators.

To take things even further, you can now customize the appearance of your documentation pages with color, font, and icon customizations. Navigation also took a step forward with quick navigation, allowing fuzzy in-project search:

A DocC documentation page showing a quick navigation overlay showing fuzzy documentation search

Swift-DocC also now supports documenting extensions to types from other modules. This is an opt-in feature and can be enabled by adding the --include-extended-types flag when using the Swift-DocC plugin.

A documentation page featuring an extension to the standard library's Collection type.

Swift Package Manager

Following are some highlights from the changes introduced to the Swift Package Manager in Swift 5.8:

See the Swift Package Manager changelog for the complete list of changes.


With the Swift 5.8-aligned release of SwiftSyntax, SwiftSyntax contains a completely re-written parser that is implemented entirely in Swift instead of relying on the C++ parser to produce a SwiftSyntax tree. While the Swift compiler still uses the old parser implemented in C++, the eventual goal is to replace the old parser entirely. The new parser has a number of advantages:

Windows Platform

Swift 5.8 continues the incremental improvements to the Windows toolchain. Some of the important work that has gone into this release cycle includes:


Official binaries are available for download from Swift.org for Xcode, Windows, and Linux. The Swift 5.8 compiler is also included in Xcode 14.3.

Swift Evolution Appendix

The following language, standard library, and Swift Package Manager proposals were accepted through the Swift Evolution process and implemented in Swift 5.8.

Language and Standard Library

Swift Package Manager