Skip to content

Commit cfc50dc

Browse files
alexandersandbergcompnerdhborlatomerddempseyatgithub
authored
Swift 5.8 release blog post (swiftlang#257)
* add first draft of 5.8 blog post * remove SE-0380 * remove SE-0381 * apply suggestion from code review * add windows platform section content Co-Authored-By: Saleem Abdulrasool <[email protected]> * Update _posts/2023-03-17-swift-5.8-released.md Co-authored-by: Saleem Abdulrasool <[email protected]> * Update _posts/2023-03-17-swift-5.8-released.md Co-authored-by: Saleem Abdulrasool <[email protected]> * add language and standard library section content Co-Authored-By: Holly Borla <[email protected]> * Update _posts/2023-03-17-swift-5.8-released.md Co-authored-by: tomer doron <[email protected]> * add release summary to introduction * fix missing hyphen in flag Co-Authored-By: James Dempsey <[email protected]> * add downloads section content * add link that explains using feature identifiers in source code * Update 2023-03-17-swift-5.8-released.md Co-Authored-By: Alex Martini <[email protected]> * Update 2023-03-17-swift-5.8-released.md Co-Authored-By: buttaface <[email protected]> Co-Authored-By: Xiaodi Wu <[email protected]> * Update 2023-03-17-swift-5.8-released.md Co-Authored-By: buttaface <[email protected]> * link out to more info about upcoming feature usage * Update _posts/2023-03-17-swift-5.8-released.md Co-authored-by: Xiaodi Wu <[email protected]> * Update 2023-03-17-swift-5.8-released.md Co-Authored-By: Xiaodi Wu <[email protected]> * smaller grammatical fixes and improvements * Update 2023-03-17-swift-5.8-released.md Co-Authored-By: Xiaodi Wu <[email protected]> * Keep SE-0376 only in the evolution appendix of 5.8 blog post * Rename blog post file * Update 2023-03-30-swift-5.8-released.md Remove hasFeature example, as getting a real-world one was too tortured. * Minor language tweaks * Update timestamp --------- Co-authored-by: Saleem Abdulrasool <[email protected]> Co-authored-by: Saleem Abdulrasool <[email protected]> Co-authored-by: Holly Borla <[email protected]> Co-authored-by: tomer doron <[email protected]> Co-authored-by: James Dempsey <[email protected]> Co-authored-by: Alex Martini <[email protected]> Co-authored-by: buttaface <[email protected]> Co-authored-by: Xiaodi Wu <[email protected]> Co-authored-by: Ted Kremenek <[email protected]> Co-authored-by: Ben Cohen <[email protected]> Co-authored-by: Christopher Thielen <[email protected]>
1 parent 642e827 commit cfc50dc

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

_data/authors.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,11 @@ svenaschmidt:
347347
gravatar: 291bc7d4b4d1aa0624248398074f5b24
348348
github: finestructure
349349
about: "Sven A. Schmidt is an independent software developer and the co-creator of the Swift Package Index."
350+
351+
alexandersandberg:
352+
name: Alexander Sandberg
353+
gravatar: 3a1582c3f0a9ef8455b504bb3e1106a7
354+
355+
github: alexandersandberg
356+
twitter: alexandberg
357+
about: "Alexander Sandberg is an iOS and macOS developer and a member of the Swift Website Workgroup."
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
layout: post
3+
published: true
4+
date: 2023-03-30 15:00:00
5+
title: Swift 5.8 Released!
6+
author: [alexandersandberg]
7+
---
8+
9+
Swift 5.8 is now officially released! 🎉 This release includes major additions to the [language and standard library](#language-and-standard-library), including `hasFeature` to support piecemeal adoption of upcoming features, an improved [developer experience](#developer-experience), improvements to tools in the Swift ecosystem including [Swift-DocC](#swift-docc), [Swift Package Manager](#swift-package-manager), and [SwiftSyntax](#swiftsyntax), refined [Windows support](#windows-platform), and more.
10+
11+
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!
12+
13+
For a quick dive into some of what’s new in Swift 5.8, check out this [playground](https://github.com/twostraws/whats-new-in-swift-5-8) put together by Paul Hudson.
14+
15+
[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/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](/documentation/#translations).
16+
17+
## Language and Standard Library
18+
19+
Swift 5.8 enables you to start incrementally preparing your projects for Swift 6 by [using _upcoming features_](https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md). By default, upcoming features are disabled. To enable a feature, pass the compiler flag `-enable-upcoming-feature` followed by the feature's identifier.
20+
21+
Feature identifiers can also be [used in source code](https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md#feature-detection-in-source-code) using `#if hasFeature(FeatureIdentifier)` so that code can still compile with older tools where the upcoming feature is not available.
22+
23+
Swift 5.8 includes upcoming features for the following Swift evolution proposals:
24+
25+
- SE-0274: [Concise magic file names](https://github.com/apple/swift-evolution/blob/main/proposals/0274-magic-file.md) (`ConciseMagicFile`)
26+
- SE-0286: [Forward-scan matching for trailing closures](https://github.com/apple/swift-evolution/blob/main/proposals/0286-forward-scan-trailing-closures.md) (`ForwardTrailingClosures`)
27+
- SE-0335: [Introduce existential any](https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md) (`ExistentialAny`)
28+
- SE-0354: [Regex literals](https://github.com/apple/swift-evolution/blob/main/proposals/0354-regex-literals.md) (`BaseSlashRegexLiterals`)
29+
30+
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:
31+
32+
```swift
33+
print(#file)
34+
print(#filePath)
35+
fatalError("Something bad happened!")
36+
```
37+
38+
The above code will produce the following output:
39+
40+
```
41+
MagicFile/0274-magic-file.swift
42+
/Users/example/Desktop/0274-magic-file.swift
43+
Fatal error: Something bad happened!: file MagicFile/0274-magic-file.swift, line 3
44+
```
45+
46+
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:
47+
48+
```swift
49+
#if hasAttribute(preconcurrency)
50+
@preconcurrency
51+
#endif
52+
protocol P: Sendable { ... }
53+
```
54+
55+
Swift 5.8 brings other language and standard library enhancements, including [unboxing for `any` arguments to optional parameters](https://github.com/apple/swift-evolution/blob/main/proposals/0375-opening-existential-optional.md), [local wrapped properties in result builders](https://github.com/apple/swift-evolution/blob/main/proposals/0373-vars-without-limits-in-result-builders.md), [improved debug printing for key paths](https://github.com/apple/swift-evolution/blob/main/proposals/0369-add-customdebugdescription-conformance-to-anykeypath.md), and more.
56+
57+
You can find the complete list of Swift Evolution proposals that were implemented in Swift 5.8 in the [Swift Evolution Appendix](#swift-evolution-appendix) below.
58+
59+
## Developer Experience
60+
61+
### Improved Result Builder Implementation
62+
63+
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](https://github.com/apple/swift-evolution/blob/main/proposals/0289-result-builders.md), which has an impact on some existing code that relied on invalid type inference.
64+
65+
The new implementation takes advantage of the [extended multi-statement closure inference](https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md) 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.
66+
67+
For more details, please refer to the [Swift Forums post](https://forums.swift.org/t/improved-result-builder-implementation-in-swift-5-8/63192) that outlines the improvements and provides more information about invalid inference scenarios.
68+
69+
## Ecosystem
70+
71+
### Swift-DocC
72+
73+
As [announced in February](https://www.swift.org/blog/tspl-on-docc/), The Swift Programming Language book has been converted to Swift-DocC and made [open source](https://github.com/apple/swift-book), and with it came some enhancements to Swift-DocC itself in the form of [option directives](https://www.swift.org/documentation/docc/options) 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](https://www.swift.org/documentation/docc/api-reference-syntax#creating-custom-page-layouts), including [Grid-based layouts](https://www.swift.org/documentation/docc/row) and [tab navigators](https://www.swift.org/documentation/docc/tab).
74+
75+
To take things even further, you can now [customize the appearance of your documentation pages](https://www.swift.org/documentation/docc/customizing-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:
76+
77+
![A DocC documentation page showing a quick navigation overlay showing fuzzy documentation search](/assets/images/5.8-blog/docc-fuzzy-search.png)
78+
79+
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](https://apple.github.io/swift-docc-plugin/documentation/swiftdoccplugin/generating-documentation-for-extended-types).
80+
81+
![A documentation page featuring an extension to the standard library's Collection type.](/assets/images/5.8-blog/docc-extended-type.png)
82+
83+
### Swift Package Manager
84+
85+
Following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.8:
86+
87+
- [SE-0362](https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md): Targets can now specify the upcoming language features they require. `Package.swift` manifest syntax has been expanded with an API to include setting `enableUpcomingFeature` and `enableExperimentalFeature` flags at the target level.
88+
89+
- [SE-0378](https://github.com/apple/swift-evolution/blob/main/proposals/0378-package-registry-auth.md): Token authentication when interacting with a package registry is now supported. The `swift package-registry` command has two new subcommands `login` and `logout` for adding/removing registry credentials.
90+
91+
- Exposing an executable product that consists solely of a binary target that is backed by an artifact bundle is now allowed. This allows vending binary executables as their own separate package, independently of the plugins that are using them.
92+
93+
- In packages using tools version 5.8 or later, Foundation is no longer implicitly imported into package manifests. If Foundation APIs are used, the module needs to be imported explicitly.
94+
95+
See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-58) for the complete list of changes.
96+
97+
### SwiftSyntax
98+
99+
With the Swift 5.8-aligned release of [SwiftSyntax](https://github.com/apple/swift-syntax), 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:
100+
101+
- Contributing to or depending on SwiftSyntax is now as easy as any other Swift package. This greatly lowers the barrier of entry for new contributors and adopters.
102+
- The new parser has been designed with error recovery as a primary goal. It is more tolerant of parsing errors and produces better error messages.
103+
- SwiftSyntaxBuilder allows generating source code in a declarative way using a mixture of result builders and string interpolation. An example can be found [here](https://github.com/apple/swift-syntax/blob/release/5.8/Examples/CodeGenerationUsingSwiftSyntaxBuilder.swift).
104+
105+
### Windows Platform
106+
107+
Swift 5.8 continues the incremental improvements to the Windows toolchain. Some of the important work that has gone into this release cycle includes:
108+
109+
- The Windows toolchain has reduced some of its dependency on environment variables. `DEVELOPER_DIR` was previously needed to locate components and this is no longer required. This cleans up the installation and enables us to get closer to per-user installation.
110+
- ICU has been changed to static linking. This reduces the number of files that need to be distributed and reduces the number of dependencies that a shipping product requires. This was made possible by the removal of the ICU dependency in the Swift standard library.
111+
- Some of the initial work to support C++ interop on Windows has been merged and is available in the toolchain. This includes the work towards modularising the Microsoft C++ Runtime (msvcprt).
112+
- The `vcruntime` module has been renamed to `visualc`. This better reflects the module and paves the road for future enhancements for bridging the Windows platform libraries.
113+
- A significant amount of work for improving path handling in the Swift Package Manager has been merged. This should help make Swift Package Manager more robust on Windows and improve interactions with SourceKit-LSP.
114+
- SourceKit-LSP has benefited from several robustness improvements. Cross-module references are now more reliable and C/C++ references have been improved thanks to the enhanced path handling in SPM which ensures that files are correctly identified.
115+
116+
## Downloads
117+
118+
Official binaries are [available for download](https://swift.org/download/) from [Swift.org](http://swift.org/) for Xcode, Windows, and Linux. The Swift 5.8 compiler is also included in [Xcode 14.3](https://apps.apple.com/app/xcode/id497799835).
119+
120+
## Swift Evolution Appendix
121+
122+
The following language, standard library, and Swift Package Manager proposals were accepted through the [Swift Evolution](https://github.com/apple/swift-evolution) process and [implemented in Swift 5.8](https://apple.github.io/swift-evolution/#?version=5.8).
123+
124+
**Language and Standard Library**
125+
126+
- SE-0274: [Concise magic file names](https://github.com/apple/swift-evolution/blob/main/proposals/0274-magic-file.md)
127+
- SE-0362: [Piecemeal adoption of upcoming language improvements](https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md)
128+
- SE-0365: [Allow implicit self for weak self captures, after self is unwrapped](https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md)
129+
- SE-0367: [Conditional compilation for attributes](https://github.com/apple/swift-evolution/blob/main/proposals/0367-conditional-attributes.md)
130+
- SE-0368: [StaticBigInt](https://github.com/apple/swift-evolution/blob/main/proposals/0368-staticbigint.md)
131+
- SE-0369: [Add CustomDebugStringConvertible conformance to AnyKeyPath](https://github.com/apple/swift-evolution/blob/main/proposals/0369-add-customdebugdescription-conformance-to-anykeypath.md)
132+
- SE-0370: [Pointer Family Initialization Improvements and Better Buffer Slices](https://github.com/apple/swift-evolution/blob/main/proposals/0370-pointer-family-initialization-improvements.md)
133+
- SE-0372: [Document Sorting as Stable](https://github.com/apple/swift-evolution/blob/main/proposals/0372-document-sorting-as-stable.md)
134+
- SE-0373: [Lift all limitations on variables in result builders](https://github.com/apple/swift-evolution/blob/main/proposals/0373-vars-without-limits-in-result-builders.md)
135+
- SE-0374: [Add sleep(for:) to Clock](https://github.com/apple/swift-evolution/blob/main/proposals/0374-clock-sleep-for.md)
136+
- SE-0375: [Opening existential arguments to optional parameters](https://github.com/apple/swift-evolution/blob/main/proposals/0375-opening-existential-optional.md)
137+
- SE-0376: [Function Back Deployment](https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md)
138+
139+
**Swift Package Manager**
140+
141+
- SE-0362: [Piecemeal adoption of upcoming language improvements](https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md)
142+
- SE-0378: [Package Registry Authentication](https://github.com/apple/swift-evolution/blob/main/proposals/0378-package-registry-auth.md)
199 KB
Loading
51.4 KB
Loading

0 commit comments

Comments
 (0)