From 113c1bf1d90de43c649bd1f0e14af7a43d82f98c Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Tue, 29 Aug 2023 09:13:12 +0200 Subject: [PATCH 01/51] add first blog post draft --- _posts/2023-08-29-swift-5.9-released.md | 99 +++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 _posts/2023-08-29-swift-5.9-released.md diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md new file mode 100644 index 000000000..35c34a192 --- /dev/null +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -0,0 +1,99 @@ +--- +layout: post +published: true +date: 2023-08-29 15:00:00 +title: Swift 5.9 Released! +author: [alexandersandberg] +--- + +Swift 5.9 is now officially released! 🎉 + +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! + + + +[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 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). + +If you’re new to Swift, [The Swift Programming Language](https://docs.swift.org/swift-book/) is the official Swift guide and has been updated for version 5.9. The Swift community maintains a number of [translations](https://www.swift.org/documentation/#translations). + +## Language and Standard Library + + + +You can find the complete list of Swift Evolution proposals that were implemented in Swift 5.9 in the [Swift Evolution Appendix](#swift-evolution-appendix) below. + +## Developer Experience + + + +### Debugging + +New features have been introduced to [LLDB](https://lldb.llvm.org/ "LLDB project home page") and the Swift compiler to improve the debugging experience, including faster `p` and `po` and use of generic type parameters in expressions. + +Learn more in this dedicated blog post: [What’s new in Swift debugging on the 5.9 branch?](#). + +## Ecosystem + + + +### Swift Package Manager + +Following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: + +- SwiftPM packages can now use `package` as a new access modifier, allowing accessing symbols in another target / module within the same package without making it public. + +- New `swift experimental-sdk` experimental command is now available for managing Swift SDK bundles that follow the format described in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). + +- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM also gains support for signed packages. Trust-on-first-use (TOFU) check which includes only fingerprints (e.g., checksums) previously has been extended to include signing identities, and it is enforced for source archives as well as package manifests. + +- Add a new `CompilerPluginSupport` module which contains the definition for macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). + +See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-59) for the complete list of changes. + +### SwiftSyntax + +[SwiftSyntax](https://github.com/apple/swift-syntax) has become an essential tool to create macros in Swift 5.9. In addition to the introduction of the modules that allow the creation of macros, SwiftSyntax has received huge focus on quality: + +- The documentation of SwiftSyntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax) + +- The names of all syntax nodes and their children have been audited to be more consistent and accurately reflect the Swift language. + +- The error messages produced by the new SwiftParser have been greatly improved and it now produces better errors than the C++ parser in almost all cases. + +- As part of the Google Summer of Code project, incremental parsing has been introduced to SwiftSyntax, allowing e.g. an editor to only reparse those parts of a syntax tree that have changed. + +Over the last year, SwiftSyntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. And community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! + +### Windows Platform + + + +## Downloads + + + +## Swift Evolution Appendix + +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.9](https://apple.github.io/swift-evolution/#?version=5.9). + +- SE-0366: [`consume` operator to end the lifetime of a variable binding](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) +- SE-0374: [Add sleep(for:) to Clock](https://github.com/apple/swift-evolution/blob/main/proposals/0374-clock-sleep-for.md) +- SE-0377: [`borrowing` and `consuming` parameter ownership modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) +- SE-0380: [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md) +- SE-0381: [DiscardingTaskGroups](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) +- SE-0382: [Expression Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md) +- SE-0384: [Importing Forward Declared Objective-C Interfaces and Protocols](https://github.com/apple/swift-evolution/blob/main/proposals/0384-importing-forward-declared-objc-interfaces-and-protocols.md) + +- SE-0388: [Convenience Async[Throwing]Stream.makeStream methods](https://github.com/apple/swift-evolution/blob/main/proposals/0388-async-stream-factory.md) +- SE-0389: [Attached Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0389-attached-macros.md) +- SE-0390: [Noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) +- SE-0392: [Custom Actor Executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) +- SE-0393: [Value and Type Parameter Packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) +- SE-0394: [Package Manager Support for Custom Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0394-swiftpm-expression-macros.md) +- SE-0396: [Conform `Never` to `Codable`](https://github.com/apple/swift-evolution/blob/main/proposals/0396-never-codable.md) +- SE-0397: [Freestanding Declaration Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0397-freestanding-declaration-macros.md) +- SE-0398: [Allow Generic Types to Abstract Over Packs](https://github.com/apple/swift-evolution/blob/main/proposals/0398-variadic-types.md) +- SE-0399: [Tuple of value pack expansion](https://github.com/apple/swift-evolution/blob/main/proposals/0399-tuple-of-value-pack-expansion.md) +- SE-0400: [Init Accessors](https://github.com/apple/swift-evolution/blob/main/proposals/0400-init-accessors.md) +- SE-0401: [Remove Actor Isolation Inference caused by Property Wrappers](https://github.com/apple/swift-evolution/blob/main/proposals/0401-remove-property-wrapper-isolation.md) +- SE-0402: [Generalize `conformance` macros as `extension` macros](https://github.com/apple/swift-evolution/blob/main/proposals/0402-extension-macros.md) From 2f8aa20a3d590e396d95103db210a98163c10d48 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Tue, 29 Aug 2023 19:15:16 +0200 Subject: [PATCH 02/51] include SE-0386 in evolutions appendix --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 35c34a192..056d1a21d 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -83,7 +83,7 @@ The following language, standard library, and Swift Package Manager proposals we - SE-0381: [DiscardingTaskGroups](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) - SE-0382: [Expression Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md) - SE-0384: [Importing Forward Declared Objective-C Interfaces and Protocols](https://github.com/apple/swift-evolution/blob/main/proposals/0384-importing-forward-declared-objc-interfaces-and-protocols.md) - +- SE-0386: [New access modifier: `package`](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) - SE-0388: [Convenience Async[Throwing]Stream.makeStream methods](https://github.com/apple/swift-evolution/blob/main/proposals/0388-async-stream-factory.md) - SE-0389: [Attached Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0389-attached-macros.md) - SE-0390: [Noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) From 1f9e12f1520bb98002c3f9e2c1932b09f4c5b4a8 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Tue, 29 Aug 2023 21:19:14 +0200 Subject: [PATCH 03/51] add c++ interoperability section --- _posts/2023-08-29-swift-5.9-released.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 056d1a21d..b44114ae5 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -64,6 +64,14 @@ See the [Swift Package Manager changelog](https://github.com/apple/swift-package Over the last year, SwiftSyntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. And community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! +### C++ Interoperability + +Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++. You can now use a subset of C++ APIs in Swift and Swift APIs from C++. For information on enabling C++ interoperability and the supported language subset, please refer to the [documentation](/documentation/cxx-interop/). + +C++ interoperability is an actively evolving feature of Swift and developed by the focused [C++ Interoperability Workgroup](/cxx-interop-workgroup/). Certain aspects of the design and functionality might change in future releases of Swift, as the Swift community gathers feedback from real world adoption in mixed Swift and C++ codebases. + +Join the Swift community and the C++ Interoperability Workgroup to provide feedback and help shape the evolution of the feature. + ### Windows Platform From 40d105701d8e5e37c8a19658d7fdc1f983c5bbee Mon Sep 17 00:00:00 2001 From: tomer doron Date: Tue, 29 Aug 2023 23:18:32 -0700 Subject: [PATCH 04/51] Update 2023-08-29-swift-5.9-released.md (#374) * Update 2023-08-29-swift-5.9-released.md * indent code block in list --------- Co-authored-by: Alexander Sandberg --- _posts/2023-08-29-swift-5.9-released.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index b44114ae5..aac33bd4f 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -42,11 +42,21 @@ Following are some highlights from the changes introduced to the [Swift Package - SwiftPM packages can now use `package` as a new access modifier, allowing accessing symbols in another target / module within the same package without making it public. -- New `swift experimental-sdk` experimental command is now available for managing Swift SDK bundles that follow the format described in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). +- Introducing `CompilerPluginSupport` module for defining macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). + +- Introducing new `.embedInCode` resource rule for embedding the contents of the resource into the executable by generating a byte array, e.g. + + ``` + struct PackageResources { + static let my_resource: [UInt8] = [104,101,108,108,111,32,119,111,114,108,100,10] + } + ``` + +- `allowNetworkConnections(scope:reason:)` setting giving a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, there is also a `--allow-network-connections` commandline flag to allow network connections for a particular scope. - SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM also gains support for signed packages. Trust-on-first-use (TOFU) check which includes only fingerprints (e.g., checksums) previously has been extended to include signing identities, and it is enforced for source archives as well as package manifests. -- Add a new `CompilerPluginSupport` module which contains the definition for macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). +- New `swift experimental-sdk` experimental command is now available for managing Swift SDK bundles that follow the format described in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-59) for the complete list of changes. From cf20b9a321c160fe9ed34392f82575c0bf2a2a6b Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Wed, 30 Aug 2023 19:35:27 +0200 Subject: [PATCH 05/51] update debugging section --- _posts/2023-08-29-swift-5.9-released.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index aac33bd4f..2c66c8493 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -28,9 +28,15 @@ You can find the complete list of Swift Evolution proposals that were implemente ### Debugging -New features have been introduced to [LLDB](https://lldb.llvm.org/ "LLDB project home page") and the Swift compiler to improve the debugging experience, including faster `p` and `po` and use of generic type parameters in expressions. +In Swift 5.9, we introduced a couple of new features to [LLDB](https://lldb.llvm.org/) and the Swift compiler aimed at making Swift debugging faster and more reliable. -Learn more in this dedicated blog post: [What’s new in Swift debugging on the 5.9 branch?](#). +The `p` and `po` commands will now bypass the Swift compiler when evaluating simple expressions, which will make printing local and member variables as fast as using the `frame variable` or `v` command. + +Swift expressions can now refer to generic type parameters. This allows setting a conditional breakpoint in a generic function that only triggers when a type parameter is instantiated with a specific concrete type. + +Finally, the debug info produced by the Swift compiler is now more precise when it comes to scoping of local variables. + +For a more detailed discussion and examples of how to use these new features we will be publishing a separate blog focussing on debugging Swift 5.9 next week! ## Ecosystem From 7518f22dae2c2ab8320d0184ddb0e9fbedc36d13 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Wed, 30 Aug 2023 19:40:24 +0200 Subject: [PATCH 06/51] update swift syntax section --- _posts/2023-08-29-swift-5.9-released.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 2c66c8493..9067270f1 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -66,19 +66,19 @@ Following are some highlights from the changes introduced to the [Swift Package See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-59) for the complete list of changes. -### SwiftSyntax +### Swift Syntax -[SwiftSyntax](https://github.com/apple/swift-syntax) has become an essential tool to create macros in Swift 5.9. In addition to the introduction of the modules that allow the creation of macros, SwiftSyntax has received huge focus on quality: +[swift-syntax](https://github.com/apple/swift-syntax) has become an essential tool to create macros in Swift 5.9. In addition to the introduction of the modules that allow the creation of macros, swift-syntax has received huge focus on quality: -- The documentation of SwiftSyntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax) +- The documentation of swift-syntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax) - The names of all syntax nodes and their children have been audited to be more consistent and accurately reflect the Swift language. - The error messages produced by the new SwiftParser have been greatly improved and it now produces better errors than the C++ parser in almost all cases. -- As part of the Google Summer of Code project, incremental parsing has been introduced to SwiftSyntax, allowing e.g. an editor to only reparse those parts of a syntax tree that have changed. +- As part of the Google Summer of Code project, incremental parsing has been introduced to swift-syntax, allowing e.g. an editor to only reparse those parts of a syntax tree that have changed. -Over the last year, SwiftSyntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. And community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! +Over the last year, swift-syntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. And community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! ### C++ Interoperability From e1bc48b47c2ea31b5fa15ff5d1e0ebedc34c6b97 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Sat, 2 Sep 2023 11:14:54 +0200 Subject: [PATCH 07/51] add language and standard library section --- _posts/2023-08-29-swift-5.9-released.md | 62 +++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 9067270f1..ba9792655 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -16,11 +16,67 @@ Thank you to everyone in the Swift community who made this release possible. You If you’re new to Swift, [The Swift Programming Language](https://docs.swift.org/swift-book/) is the official Swift guide and has been updated for version 5.9. The Swift community maintains a number of [translations](https://www.swift.org/documentation/#translations). -## Language and Standard Library +## Language and Standard library - +Swift 5.9 tackles three long-desired features that allow you to express things you couldn't easily do before. + +Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create new language features that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be called with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can't be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library's users to adopt powerful capabilities that adapt to the code they're used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. + +Swift also has new features to help developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to de-initialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. And [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can't be meaningfully copied when it's assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. + +The last of these major features is [parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md). These let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the `Optional`s wrap different types: + +```swift +/// Takes any number of `Optional` arguments and returns `nil` if any of them +/// are `nil`, or a tuple of their values if all of them are non-`nil`. +func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? { + /// Accumulates the results from the `checkNilness(of:)` helper function. + var anyAreNil = false + + // Check if any of the arguments in `each optional` is nil by running this + // `checkNilness(of:)` function on each argument. + func checkNilness(of oneOptional: OneWrapped?) { + if oneOptional == nil { + anyAreNil = true + } + } + repeat checkNilness(of: each optional) + + // Did `checkNilness(of:)` find any nils? If so, return nil early. + if anyAreNil { + return nil + } + + // Otherwise, we can safely force-unwrap all of the arguments and form a tuple + // from the unwrapped values. + return (repeat (each optional)!) +} + +let optionalInt: Int? = 1 +let optionalDouble: Double? = 2.5 +let optionalString: String? = nil + +if let (int, double, string) = all(optionalInt, optionalDouble, optionalString) { + print(int, double, string) +} +else { + print("got a nil") +} +``` + +What's more, these features are all usable today in Swift 5.9, but they are not finished growing. Each one is too large to fully implement in a single release; we're excited about what you can already do with them in Swift 5.9, but we're even more excited to have laid the foundations for better things to come. + +In addition to these major features, Swift 5.9 also includes lots of smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: + +```swift +statusBar.text = if !hasConnection { "Disconnected" } + else if let error = lastError { error.localizedDescription } + else { "Ready" } +``` + +Swift 5.9 also adds a [new `package` access level](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) that lets other modules in the same package access APIs, but hides them from code outside the package; it's great for splitting up large modules into several smaller ones without exposing internals to the package's clients. Developers using Swift Concurrency may appreciate the [more convenient `DiscardingTaskGroup` types](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) for task groups that don't generate results and the advanced [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) feature for controlling the exact environment that an actor is run in. -You can find the complete list of Swift Evolution proposals that were implemented in Swift 5.9 in the [Swift Evolution Appendix](#swift-evolution-appendix) below. +A full list of Swift 5.9's Evolution proposals can be found at the end of this post. ## Developer Experience From 9bf6871b749970993670b26d39fbd6a8fedd55f3 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Sat, 2 Sep 2023 11:19:37 +0200 Subject: [PATCH 08/51] fix casing of section title --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index ba9792655..22614ceb5 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -16,7 +16,7 @@ Thank you to everyone in the Swift community who made this release possible. You If you’re new to Swift, [The Swift Programming Language](https://docs.swift.org/swift-book/) is the official Swift guide and has been updated for version 5.9. The Swift community maintains a number of [translations](https://www.swift.org/documentation/#translations). -## Language and Standard library +## Language and Standard Library Swift 5.9 tackles three long-desired features that allow you to express things you couldn't easily do before. From d147e4a3900d40c42381cf08016da64076fd1a02 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Mon, 4 Sep 2023 15:30:51 +0100 Subject: [PATCH 09/51] Add a Crash Handling subsection. (#376) Add some words about the new crash handler, including a promise of a future blog post on the subject. --- _posts/2023-08-29-swift-5.9-released.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 22614ceb5..57093244c 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -82,6 +82,14 @@ A full list of Swift 5.9's Evolution proposals can be found at the end of this p +### Crash Handling + +On Linux, the Swift runtime will now catch program crashes and Swift runtime errors and display a backtrace on the program's output. The backtracer is out-of-process and includes support for `async` functions. + +This feature is also available on macOS, although there it is disabled by default (it can be enabled by setting `SWIFT_BACKTRACE=enable=yes`) and you need to ensure that your program is signed with the `com.apple.security.get-task-allow` entitlement. + +A more detailed blog covering this feature will be published soon. + ### Debugging In Swift 5.9, we introduced a couple of new features to [LLDB](https://lldb.llvm.org/) and the Swift compiler aimed at making Swift debugging faster and more reliable. From 1171ead12ae37270e712b62abb1bb33ad7f14af6 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Tue, 5 Sep 2023 06:38:28 +0200 Subject: [PATCH 10/51] remove completed TODOs --- _posts/2023-08-29-swift-5.9-released.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 57093244c..00d799c4d 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -80,11 +80,9 @@ A full list of Swift 5.9's Evolution proposals can be found at the end of this p ## Developer Experience - - ### Crash Handling -On Linux, the Swift runtime will now catch program crashes and Swift runtime errors and display a backtrace on the program's output. The backtracer is out-of-process and includes support for `async` functions. +On Linux, the Swift runtime will now catch program crashes and Swift runtime errors and display a backtrace on the program's output. The backtracer is out-of-process and includes support for `async` functions. This feature is also available on macOS, although there it is disabled by default (it can be enabled by setting `SWIFT_BACKTRACE=enable=yes`) and you need to ensure that your program is signed with the `com.apple.security.get-task-allow` entitlement. @@ -104,8 +102,6 @@ For a more detailed discussion and examples of how to use these new features we ## Ecosystem - - ### Swift Package Manager Following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: From dd2d3a187446ede8c179942efdd87ffbcdaa61a0 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Tue, 5 Sep 2023 20:44:43 +0200 Subject: [PATCH 11/51] add details element to hide code snippet --- _posts/2023-08-29-swift-5.9-released.md | 33 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 00d799c4d..70ba0a72c 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -26,6 +26,26 @@ Swift also has new features to help developers fine-tune memory management behav The last of these major features is [parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md). These let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the `Optional`s wrap different types: +```swift +func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? { + // Implementation provided below +} + +let optionalInt: Int? = 1 +let optionalDouble: Double? = 2.5 +let optionalString: String? = nil + +if let (int, double, string) = all(optionalInt, optionalDouble, optionalString) { + print(int, double, string) +} +else { + print("got a nil") +} +``` + +
+ Implementation of all + ```swift /// Takes any number of `Optional` arguments and returns `nil` if any of them /// are `nil`, or a tuple of their values if all of them are non-`nil`. @@ -51,19 +71,10 @@ func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapp // from the unwrapped values. return (repeat (each optional)!) } - -let optionalInt: Int? = 1 -let optionalDouble: Double? = 2.5 -let optionalString: String? = nil - -if let (int, double, string) = all(optionalInt, optionalDouble, optionalString) { - print(int, double, string) -} -else { - print("got a nil") -} ``` +
+ What's more, these features are all usable today in Swift 5.9, but they are not finished growing. Each one is too large to fully implement in a single release; we're excited about what you can already do with them in Swift 5.9, but we're even more excited to have laid the foundations for better things to come. In addition to these major features, Swift 5.9 also includes lots of smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: From 8e492da79a5fef9d5886d078d112deba89d3908e Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Tue, 5 Sep 2023 20:47:36 +0200 Subject: [PATCH 12/51] add SE-0395 to evolutions list --- _posts/2023-08-29-swift-5.9-released.md | 1 + 1 file changed, 1 insertion(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 70ba0a72c..f2ddbbcb1 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -185,6 +185,7 @@ The following language, standard library, and Swift Package Manager proposals we - SE-0392: [Custom Actor Executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) - SE-0393: [Value and Type Parameter Packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) - SE-0394: [Package Manager Support for Custom Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0394-swiftpm-expression-macros.md) +- SE-0395: [Observation](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md) - SE-0396: [Conform `Never` to `Codable`](https://github.com/apple/swift-evolution/blob/main/proposals/0396-never-codable.md) - SE-0397: [Freestanding Declaration Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0397-freestanding-declaration-macros.md) - SE-0398: [Allow Generic Types to Abstract Over Packs](https://github.com/apple/swift-evolution/blob/main/proposals/0398-variadic-types.md) From 0fa3a86fcc2bdfe980b4ffffe5cf1ba2faa0afbe Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Thu, 7 Sep 2023 21:47:46 +0100 Subject: [PATCH 13/51] Remove promise of a future blog post. (#381) --- _posts/2023-08-29-swift-5.9-released.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index f2ddbbcb1..06a5a9411 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -97,8 +97,6 @@ On Linux, the Swift runtime will now catch program crashes and Swift runtime err This feature is also available on macOS, although there it is disabled by default (it can be enabled by setting `SWIFT_BACKTRACE=enable=yes`) and you need to ensure that your program is signed with the `com.apple.security.get-task-allow` entitlement. -A more detailed blog covering this feature will be published soon. - ### Debugging In Swift 5.9, we introduced a couple of new features to [LLDB](https://lldb.llvm.org/) and the Swift compiler aimed at making Swift debugging faster and more reliable. From 79798f760af10619a20dfdc6ec8034aa9990ab0d Mon Sep 17 00:00:00 2001 From: tomer doron Date: Fri, 8 Sep 2023 13:12:59 -0700 Subject: [PATCH 14/51] Update _posts/2023-08-29-swift-5.9-released.md --- _posts/2023-08-29-swift-5.9-released.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 06a5a9411..3d948ec33 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -157,6 +157,10 @@ C++ interoperability is an actively evolving feature of Swift and developed by t Join the Swift community and the C++ Interoperability Workgroup to provide feedback and help shape the evolution of the feature. +### Server + +The server workgroup has been busy driving the adoption of Swift concurrency in the server ecosystem, including making use of new 5.9 features such as [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md). The group recently published their [annual update for 2023](https://www.swift.org/blog/sswg-update-2023/) which goes into details of this work. + ### Windows Platform From 06e45f42b7c14185bd8ae98d7f040ea7ec0dc330 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Sun, 10 Sep 2023 21:13:39 -0700 Subject: [PATCH 15/51] Updates to the 5.9 blog post draft. (#398) * Add initial draft of the Windows section from Saleem. * Add a draft for the introduction to the 5.9 release blog post. * Minor editorial pass based on PR feedback. --- _posts/2023-08-29-swift-5.9-released.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 3d948ec33..914cc00e7 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -6,7 +6,7 @@ title: Swift 5.9 Released! author: [alexandersandberg] --- -Swift 5.9 is now officially released! 🎉 +Swift 5.9 is now officially released! 🎉 Swift 5.9 is the foundation for many long-awaited features that give library authors more expressive power, including a new macro system and parameter packs, improve the debugging experience through enhanced crash logs and new features in LLDB's expression evaluator, Swift Package Manager support for a new `package` access modifier and macro targets, bi-directional interoperability with C++, Windows platform improvements, 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! @@ -14,8 +14,6 @@ Thank you to everyone in the Swift community who made this release possible. You [The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 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). -If you’re new to Swift, [The Swift Programming Language](https://docs.swift.org/swift-book/) is the official Swift guide and has been updated for version 5.9. The Swift community maintains a number of [translations](https://www.swift.org/documentation/#translations). - ## Language and Standard Library Swift 5.9 tackles three long-desired features that allow you to express things you couldn't easily do before. @@ -77,7 +75,7 @@ func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapp What's more, these features are all usable today in Swift 5.9, but they are not finished growing. Each one is too large to fully implement in a single release; we're excited about what you can already do with them in Swift 5.9, but we're even more excited to have laid the foundations for better things to come. -In addition to these major features, Swift 5.9 also includes lots of smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: +In addition to these major features, Swift 5.9 also includes smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: ```swift statusBar.text = if !hasConnection { "Disconnected" } @@ -107,7 +105,7 @@ Swift expressions can now refer to generic type parameters. This allows setting Finally, the debug info produced by the Swift compiler is now more precise when it comes to scoping of local variables. -For a more detailed discussion and examples of how to use these new features we will be publishing a separate blog focussing on debugging Swift 5.9 next week! +For a more detailed discussion and examples of how to use these new features, stay tuned for a dedicated blog about debugging in Swift 5.9 coming soon! ## Ecosystem @@ -137,9 +135,9 @@ See the [Swift Package Manager changelog](https://github.com/apple/swift-package ### Swift Syntax -[swift-syntax](https://github.com/apple/swift-syntax) has become an essential tool to create macros in Swift 5.9. In addition to the introduction of the modules that allow the creation of macros, swift-syntax has received huge focus on quality: +[swift-syntax](https://github.com/apple/swift-syntax) has become an essential tool to create macros in Swift 5.9. In addition to the introduction of the modules that allow the creation of macros, swift-syntax has received major quality improvements: -- The documentation of swift-syntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax) +- The documentation of swift-syntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax). - The names of all syntax nodes and their children have been audited to be more consistent and accurately reflect the Swift language. @@ -163,7 +161,15 @@ The server workgroup has been busy driving the adoption of Swift concurrency in ### Windows Platform - +The Windows installation received new functionality to inject the module maps via a VFS overlay dynamically rather than needing to modify the Visual Studio installation. This change finally breaks the dependency order for installation. It should now be possible to install either Visual Studio or the Swift toolchain first. Additionally, there should be no need to repair the installation after an upgrade to Visual Studio. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation was merged. This begins laying the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. + +Alongside of this improvement of handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. This change should be generally transparent to existing code. + +Structured Concurrency is now be significantly more stable on Windows. Unfortunately, this does come at the expense of backtraces as the Windows ABI currently prohibits the necessary optimizations required for the proper implementation of the feature. + +Improvements to path handling in the LSP and SPM should make both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows. It should now be possible to use LLDB on Windows for basic debugging. While still a work in progress, this should significantly improve the developer experience on Windows. + +Small improvements continue to be made to try to reduce the size of the toolchain. Although the impact of this is minimal, some of the tools are now smaller in size due to more careful curation of linking. This also reduces the number of artifacts that are contained in a toolchain installation. ## Downloads From c2af136df1d520714e217fc5354405027f9413a2 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Sun, 10 Sep 2023 21:37:23 -0700 Subject: [PATCH 16/51] Editorial pass for more consistent language and section structure. --- _posts/2023-08-29-swift-5.9-released.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 914cc00e7..1d757d3ff 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -97,7 +97,7 @@ This feature is also available on macOS, although there it is disabled by defaul ### Debugging -In Swift 5.9, we introduced a couple of new features to [LLDB](https://lldb.llvm.org/) and the Swift compiler aimed at making Swift debugging faster and more reliable. +Swift 5.9 introduces new features to [LLDB](https://lldb.llvm.org/) and the Swift compiler aimed at making Swift debugging faster and more reliable. The `p` and `po` commands will now bypass the Swift compiler when evaluating simple expressions, which will make printing local and member variables as fast as using the `frame variable` or `v` command. @@ -115,9 +115,9 @@ Following are some highlights from the changes introduced to the [Swift Package - SwiftPM packages can now use `package` as a new access modifier, allowing accessing symbols in another target / module within the same package without making it public. -- Introducing `CompilerPluginSupport` module for defining macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). +- The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). -- Introducing new `.embedInCode` resource rule for embedding the contents of the resource into the executable by generating a byte array, e.g. +- The new `.embedInCode` resource rule allows embedding the contents of the resource into the executable by generating a byte array, e.g. ``` struct PackageResources { @@ -125,11 +125,11 @@ Following are some highlights from the changes introduced to the [Swift Package } ``` -- `allowNetworkConnections(scope:reason:)` setting giving a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, there is also a `--allow-network-connections` commandline flag to allow network connections for a particular scope. +- The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, there is also a `--allow-network-connections` commandline flag to allow network connections for a particular scope. - SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM also gains support for signed packages. Trust-on-first-use (TOFU) check which includes only fingerprints (e.g., checksums) previously has been extended to include signing identities, and it is enforced for source archives as well as package manifests. -- New `swift experimental-sdk` experimental command is now available for managing Swift SDK bundles that follow the format described in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). +- A new `swift experimental-sdk` experimental command is now available for managing Swift SDK bundles that follow the format described in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-59) for the complete list of changes. @@ -161,15 +161,15 @@ The server workgroup has been busy driving the adoption of Swift concurrency in ### Windows Platform -The Windows installation received new functionality to inject the module maps via a VFS overlay dynamically rather than needing to modify the Visual Studio installation. This change finally breaks the dependency order for installation. It should now be possible to install either Visual Studio or the Swift toolchain first. Additionally, there should be no need to repair the installation after an upgrade to Visual Studio. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation was merged. This begins laying the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. +The Windows installation received new functionality to inject the module maps via a VFS overlay dynamically rather than needing to modify the Visual Studio installation. This change breaks the dependency order for installation; it is now possible to install either Visual Studio or the Swift toolchain first. This also eliminates the need to repair the installation after an upgrade to Visual Studio. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation lays the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. -Alongside of this improvement of handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. This change should be generally transparent to existing code. +Alongside of this improvement of handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. -Structured Concurrency is now be significantly more stable on Windows. Unfortunately, this does come at the expense of backtraces as the Windows ABI currently prohibits the necessary optimizations required for the proper implementation of the feature. +Structured Concurrency is now be significantly more stable on Windows. Backtraces are still a work in progress, as the Windows ABI currently prohibits the necessary optimizations required for the proper implementation of the feature. -Improvements to path handling in the LSP and SPM should make both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows. It should now be possible to use LLDB on Windows for basic debugging. While still a work in progress, this should significantly improve the developer experience on Windows. +Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this significantly improves the developer experience on Windows. -Small improvements continue to be made to try to reduce the size of the toolchain. Although the impact of this is minimal, some of the tools are now smaller in size due to more careful curation of linking. This also reduces the number of artifacts that are contained in a toolchain installation. +Small improvements continue to be made to reduce the size of the toolchain. Although the impact of this is minimal, some of the tools are now smaller in size due to more careful curation of linking. This also reduces the number of artifacts that are contained in a toolchain installation. ## Downloads From 9fe1cc8511f5f80fccb490cd90df4acd4b5522a6 Mon Sep 17 00:00:00 2001 From: tomer doron Date: Tue, 12 Sep 2023 16:35:53 -0700 Subject: [PATCH 17/51] Update _posts/2023-08-29-swift-5.9-released.md --- _posts/2023-08-29-swift-5.9-released.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 1d757d3ff..5db571ba4 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -159,6 +159,10 @@ Join the Swift community and the C++ Interoperability Workgroup to provide feedb The server workgroup has been busy driving the adoption of Swift concurrency in the server ecosystem, including making use of new 5.9 features such as [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md). The group recently published their [annual update for 2023](https://www.swift.org/blog/sswg-update-2023/) which goes into details of this work. +### Website + +Along side the 5.9 release, the website workgroup has revamped the content on some of the key pages of [swift.org](http://swift.org/), including a richer home page, new and detailed getting-started guides, and clearer download and install instructions. + ### Windows Platform The Windows installation received new functionality to inject the module maps via a VFS overlay dynamically rather than needing to modify the Visual Studio installation. This change breaks the dependency order for installation; it is now possible to install either Visual Studio or the Swift toolchain first. This also eliminates the need to repair the installation after an upgrade to Visual Studio. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation lays the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. From a183a95bd46bed851c2947221e2d383b63cdfe23 Mon Sep 17 00:00:00 2001 From: tomer doron Date: Tue, 12 Sep 2023 16:38:24 -0700 Subject: [PATCH 18/51] Update _posts/2023-08-29-swift-5.9-released.md --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 5db571ba4..530be3bdf 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -127,7 +127,7 @@ Following are some highlights from the changes introduced to the [Swift Package - The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, there is also a `--allow-network-connections` commandline flag to allow network connections for a particular scope. -- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM also gains support for signed packages. Trust-on-first-use (TOFU) check which includes only fingerprints (e.g., checksums) previously has been extended to include signing identities, and it is enforced for source archives as well as package manifests. +- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM also gains support for signed packages. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. - A new `swift experimental-sdk` experimental command is now available for managing Swift SDK bundles that follow the format described in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). From 019cfc382d19208ea1568c0398b7873c47f226d7 Mon Sep 17 00:00:00 2001 From: tomer doron Date: Tue, 12 Sep 2023 16:41:26 -0700 Subject: [PATCH 19/51] Update _posts/2023-08-29-swift-5.9-released.md --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 530be3bdf..fcc5e3707 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -113,7 +113,7 @@ For a more detailed discussion and examples of how to use these new features, st Following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: -- SwiftPM packages can now use `package` as a new access modifier, allowing accessing symbols in another target / module within the same package without making it public. +- Packages can make use of the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. - The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). From 0121079e930d4491c059098500b37a22589fc3b2 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Thu, 14 Sep 2023 10:21:41 +0200 Subject: [PATCH 20/51] use smart quotes Co-Authored-By: James Dempsey <470139+dempseyatgithub@users.noreply.github.com> --- _posts/2023-08-29-swift-5.9-released.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index fcc5e3707..520105822 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -6,7 +6,7 @@ title: Swift 5.9 Released! author: [alexandersandberg] --- -Swift 5.9 is now officially released! 🎉 Swift 5.9 is the foundation for many long-awaited features that give library authors more expressive power, including a new macro system and parameter packs, improve the debugging experience through enhanced crash logs and new features in LLDB's expression evaluator, Swift Package Manager support for a new `package` access modifier and macro targets, bi-directional interoperability with C++, Windows platform improvements, and more. +Swift 5.9 is now officially released! 🎉 Swift 5.9 is the foundation for many long-awaited features that give library authors more expressive power, including a new macro system and parameter packs, improve the debugging experience through enhanced crash logs and new features in LLDB’s expression evaluator, Swift Package Manager support for a new `package` access modifier and macro targets, bi-directional interoperability with C++, Windows platform improvements, 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! @@ -16,11 +16,11 @@ Thank you to everyone in the Swift community who made this release possible. You ## Language and Standard Library -Swift 5.9 tackles three long-desired features that allow you to express things you couldn't easily do before. +Swift 5.9 tackles three long-desired features that allow you to express things you couldn’t easily do before. -Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create new language features that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be called with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can't be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library's users to adopt powerful capabilities that adapt to the code they're used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. +Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create new language features that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be called with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. -Swift also has new features to help developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to de-initialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. And [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can't be meaningfully copied when it's assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. +Swift also has new features to help developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to de-initialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. And [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. The last of these major features is [parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md). These let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the `Optional`s wrap different types: @@ -73,7 +73,7 @@ func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapp -What's more, these features are all usable today in Swift 5.9, but they are not finished growing. Each one is too large to fully implement in a single release; we're excited about what you can already do with them in Swift 5.9, but we're even more excited to have laid the foundations for better things to come. +What’s more, these features are all usable today in Swift 5.9, but they are not finished growing. Each one is too large to fully implement in a single release; we’re excited about what you can already do with them in Swift 5.9, but we’re even more excited to have laid the foundations for better things to come. In addition to these major features, Swift 5.9 also includes smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: @@ -83,15 +83,15 @@ statusBar.text = if !hasConnection { "Disconnected" } else { "Ready" } ``` -Swift 5.9 also adds a [new `package` access level](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) that lets other modules in the same package access APIs, but hides them from code outside the package; it's great for splitting up large modules into several smaller ones without exposing internals to the package's clients. Developers using Swift Concurrency may appreciate the [more convenient `DiscardingTaskGroup` types](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) for task groups that don't generate results and the advanced [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) feature for controlling the exact environment that an actor is run in. +Swift 5.9 also adds a [new `package` access level](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) that lets other modules in the same package access APIs, but hides them from code outside the package; it’s great for splitting up large modules into several smaller ones without exposing internals to the package’s clients. Developers using Swift Concurrency may appreciate the [more convenient `DiscardingTaskGroup` types](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) for task groups that don’t generate results and the advanced [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) feature for controlling the exact environment that an actor is run in. -A full list of Swift 5.9's Evolution proposals can be found at the end of this post. +A full list of Swift 5.9’s Evolution proposals can be found at the end of this post. ## Developer Experience ### Crash Handling -On Linux, the Swift runtime will now catch program crashes and Swift runtime errors and display a backtrace on the program's output. The backtracer is out-of-process and includes support for `async` functions. +On Linux, the Swift runtime will now catch program crashes and Swift runtime errors and display a backtrace on the program’s output. The backtracer is out-of-process and includes support for `async` functions. This feature is also available on macOS, although there it is disabled by default (it can be enabled by setting `SWIFT_BACKTRACE=enable=yes`) and you need to ensure that your program is signed with the `com.apple.security.get-task-allow` entitlement. @@ -113,7 +113,7 @@ For a more detailed discussion and examples of how to use these new features, st Following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: -- Packages can make use of the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. +- Packages can make use of the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. - The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). From da1c49324a35bc9ec1f71bdf95424cfbcc367de8 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Thu, 14 Sep 2023 10:45:57 +0200 Subject: [PATCH 21/51] address PR feedback Co-Authored-By: James Dempsey <470139+dempseyatgithub@users.noreply.github.com> Co-Authored-By: finagolfin <48358669+finagolfin@users.noreply.github.com> --- _posts/2023-08-29-swift-5.9-released.md | 30 +++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 520105822..efaa8da55 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -20,9 +20,9 @@ Swift 5.9 tackles three long-desired features that allow you to express things y Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create new language features that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be called with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. -Swift also has new features to help developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to de-initialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. And [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. +Swift also has new features to help developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to deinitialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. Finally, [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. -The last of these major features is [parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md). These let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the `Optional`s wrap different types: +The last of these major features is [parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md). These let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the optionals wrap different types: ```swift func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? { @@ -73,9 +73,9 @@ func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapp -What’s more, these features are all usable today in Swift 5.9, but they are not finished growing. Each one is too large to fully implement in a single release; we’re excited about what you can already do with them in Swift 5.9, but we’re even more excited to have laid the foundations for better things to come. +What’s more, these features are all usable today in Swift 5.9, but they are not finished evolving. Each one is too large to fully implement in a single release; we’re excited about what you can already do with them in Swift 5.9, but we’re even more excited to have laid the foundations for better things to come. -In addition to these major features, Swift 5.9 also includes smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: +In addition to these major features, Swift 5.9 also includes many smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: ```swift statusBar.text = if !hasConnection { "Disconnected" } @@ -83,9 +83,11 @@ statusBar.text = if !hasConnection { "Disconnected" } else { "Ready" } ``` -Swift 5.9 also adds a [new `package` access level](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) that lets other modules in the same package access APIs, but hides them from code outside the package; it’s great for splitting up large modules into several smaller ones without exposing internals to the package’s clients. Developers using Swift Concurrency may appreciate the [more convenient `DiscardingTaskGroup` types](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) for task groups that don’t generate results and the advanced [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) feature for controlling the exact environment that an actor is run in. +Swift 5.9 also adds a [new `package` access level](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) that lets other modules in the same package access APIs, but hides them from code outside the package. It’s great for splitting up large modules into several smaller ones without exposing internals to the package’s clients. -A full list of Swift 5.9’s Evolution proposals can be found at the end of this post. +Developers using Swift Concurrency may appreciate the [more convenient `DiscardingTaskGroup` types](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) for task groups that don’t generate results and the advanced [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) feature for controlling the exact environment that an actor is run in. + +A full list of Swift 5.9 Evolution proposals can be found at the end of this post. ## Developer Experience @@ -93,7 +95,7 @@ A full list of Swift 5.9’s Evolution proposals can be found at the end of this On Linux, the Swift runtime will now catch program crashes and Swift runtime errors and display a backtrace on the program’s output. The backtracer is out-of-process and includes support for `async` functions. -This feature is also available on macOS, although there it is disabled by default (it can be enabled by setting `SWIFT_BACKTRACE=enable=yes`) and you need to ensure that your program is signed with the `com.apple.security.get-task-allow` entitlement. +This feature is also available on macOS, but is disabled by default. To enable it, set `SWIFT_BACKTRACE=enable=yes` and sign your program with the `com.apple.security.get-task-allow` entitlement. ### Debugging @@ -111,7 +113,7 @@ For a more detailed discussion and examples of how to use these new features, st ### Swift Package Manager -Following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: +The following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: - Packages can make use of the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. @@ -125,7 +127,7 @@ Following are some highlights from the changes introduced to the [Swift Package } ``` -- The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, there is also a `--allow-network-connections` commandline flag to allow network connections for a particular scope. +- The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, there is also a `--allow-network-connections` command-line flag to allow network connections for a particular scope. - SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM also gains support for signed packages. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. @@ -145,7 +147,7 @@ See the [Swift Package Manager changelog](https://github.com/apple/swift-package - As part of the Google Summer of Code project, incremental parsing has been introduced to swift-syntax, allowing e.g. an editor to only reparse those parts of a syntax tree that have changed. -Over the last year, swift-syntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. And community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! +Over the last year, swift-syntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. In addition, community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! ### C++ Interoperability @@ -157,19 +159,19 @@ Join the Swift community and the C++ Interoperability Workgroup to provide feedb ### Server -The server workgroup has been busy driving the adoption of Swift concurrency in the server ecosystem, including making use of new 5.9 features such as [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md). The group recently published their [annual update for 2023](https://www.swift.org/blog/sswg-update-2023/) which goes into details of this work. +The server workgroup has been busy driving the adoption of Swift concurrency in the server ecosystem, including making use of new 5.9 features such as [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md). The group recently published their [annual update for 2023](/blog/sswg-update-2023/) which goes into details of this work. ### Website -Along side the 5.9 release, the website workgroup has revamped the content on some of the key pages of [swift.org](http://swift.org/), including a richer home page, new and detailed getting-started guides, and clearer download and install instructions. +Along with the 5.9 release, the website workgroup has revamped the content on key pages of [Swift.org](/), including a richer home page, new and detailed getting-started guides, and clearer download and install instructions. ### Windows Platform The Windows installation received new functionality to inject the module maps via a VFS overlay dynamically rather than needing to modify the Visual Studio installation. This change breaks the dependency order for installation; it is now possible to install either Visual Studio or the Swift toolchain first. This also eliminates the need to repair the installation after an upgrade to Visual Studio. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation lays the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. -Alongside of this improvement of handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. +Alongside this improved handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK, enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. -Structured Concurrency is now be significantly more stable on Windows. Backtraces are still a work in progress, as the Windows ABI currently prohibits the necessary optimizations required for the proper implementation of the feature. +Structured Concurrency is now significantly more stable on Windows. Backtraces are still a work in progress, as the Windows ABI currently prohibits the necessary optimizations required for the proper implementation of the feature. Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this significantly improves the developer experience on Windows. From 475a1d7465dd13b0868ae89d9a83fed255f77f3d Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Thu, 14 Sep 2023 22:32:04 -0700 Subject: [PATCH 22/51] Improvements to the release blog post introduction. --- _posts/2023-08-29-swift-5.9-released.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index efaa8da55..be95f6593 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -2,18 +2,22 @@ layout: post published: true date: 2023-08-29 15:00:00 -title: Swift 5.9 Released! +title: Swift 5.9 Released author: [alexandersandberg] --- -Swift 5.9 is now officially released! 🎉 Swift 5.9 is the foundation for many long-awaited features that give library authors more expressive power, including a new macro system and parameter packs, improve the debugging experience through enhanced crash logs and new features in LLDB’s expression evaluator, Swift Package Manager support for a new `package` access modifier and macro targets, bi-directional interoperability with C++, Windows platform improvements, and more. +Swift 5.9 is now available! 🎉 + +This is a major new release that **adds an expressive macro system to the language** and introduces **support for integrating Swift into C++ codebases** through bidirectional interoperability. + +It also introduces parameter packs, an improved expression evaluator while debugging, enhanced crash handling, Windows platform improvements, and more. + +Read on for a deep dive into changes to the language, standard library, tooling, platform support, and next steps for getting started with Swift 5.9. 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! -[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 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). - ## Language and Standard Library Swift 5.9 tackles three long-desired features that allow you to express things you couldn’t easily do before. @@ -181,6 +185,10 @@ Small improvements continue to be made to reduce the size of the toolchain. Alth +## Language Guide + +[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 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). + ## Swift Evolution Appendix 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.9](https://apple.github.io/swift-evolution/#?version=5.9). From 2d316a294ec06fb46cf4b721806b777a77a99104 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Thu, 14 Sep 2023 22:56:21 -0700 Subject: [PATCH 23/51] Improve the framing of the language introduction, and flip the order of parameter packs a noncopyable types. --- _posts/2023-08-29-swift-5.9-released.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index be95f6593..d83ae5a1c 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -20,13 +20,11 @@ Thank you to everyone in the Swift community who made this release possible. You ## Language and Standard Library -Swift 5.9 tackles three long-desired features that allow you to express things you couldn’t easily do before. +Swift 5.9 tackles three long-desired features that build upon the fundamental goals of clear and concise code while maintaining safety and efficiency. A new macro system unlocks more expressive power for libraries, parameter packs make overloaded APIs more natural to use, and new ownership features offer more performance control in low-level code. Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create new language features that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be called with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. -Swift also has new features to help developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to deinitialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. Finally, [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. - -The last of these major features is [parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md). These let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the optionals wrap different types: +[Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the optionals wrap different types: ```swift func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? { @@ -77,6 +75,8 @@ func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapp +The last of these major features helps developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to deinitialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. Finally, [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. + What’s more, these features are all usable today in Swift 5.9, but they are not finished evolving. Each one is too large to fully implement in a single release; we’re excited about what you can already do with them in Swift 5.9, but we’re even more excited to have laid the foundations for better things to come. In addition to these major features, Swift 5.9 also includes many smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: From 3e08eb39a4fc307876d7d7843ac72a4bac40c54b Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Thu, 14 Sep 2023 23:07:04 -0700 Subject: [PATCH 24/51] Minor editorial changes in the debugging section. --- _posts/2023-08-29-swift-5.9-released.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index d83ae5a1c..82e090e52 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -105,14 +105,12 @@ This feature is also available on macOS, but is disabled by default. To enable i Swift 5.9 introduces new features to [LLDB](https://lldb.llvm.org/) and the Swift compiler aimed at making Swift debugging faster and more reliable. -The `p` and `po` commands will now bypass the Swift compiler when evaluating simple expressions, which will make printing local and member variables as fast as using the `frame variable` or `v` command. +The `p` and `po` commands now print local variables and properties as fast as the `frame variable` or `v` commands by bypassing the Swift compiler when evaluating simple expressions. Swift expressions can now refer to generic type parameters. This allows setting a conditional breakpoint in a generic function that only triggers when a type parameter is instantiated with a specific concrete type. Finally, the debug info produced by the Swift compiler is now more precise when it comes to scoping of local variables. -For a more detailed discussion and examples of how to use these new features, stay tuned for a dedicated blog about debugging in Swift 5.9 coming soon! - ## Ecosystem ### Swift Package Manager From 2eb95abaa25336fe5860a61abd5e61c239a28098 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Thu, 14 Sep 2023 23:15:22 -0700 Subject: [PATCH 25/51] Minor editorial changes in the Swift Syntax section. --- _posts/2023-08-29-swift-5.9-released.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 82e090e52..7023d3cab 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -139,15 +139,15 @@ See the [Swift Package Manager changelog](https://github.com/apple/swift-package ### Swift Syntax -[swift-syntax](https://github.com/apple/swift-syntax) has become an essential tool to create macros in Swift 5.9. In addition to the introduction of the modules that allow the creation of macros, swift-syntax has received major quality improvements: +[swift-syntax](https://github.com/apple/swift-syntax) is an essential tool for parsing Swift code, and it helps to power new macro libraries. This year, swift-syntax received a number of major improvements: -- The documentation of swift-syntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax). +- Syntax nodes names are more consistent and accurately reflect the Swift language. -- The names of all syntax nodes and their children have been audited to be more consistent and accurately reflect the Swift language. +- Error recovery in the new SwiftParser is greatly improved, leading to more precise error messages for incorrect or missing syntax. -- The error messages produced by the new SwiftParser have been greatly improved and it now produces better errors than the C++ parser in almost all cases. +- Incremental parsing is now supported, allowing tools such as an editor to only reparse those parts of a syntax tree that have changed. -- As part of the Google Summer of Code project, incremental parsing has been introduced to swift-syntax, allowing e.g. an editor to only reparse those parts of a syntax tree that have changed. +- The documentation of swift-syntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax). Over the last year, swift-syntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. In addition, community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! From 902fa61a3a00330d63bef1454f569ca94dd706eb Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 09:32:47 -0700 Subject: [PATCH 26/51] Editorial changes for the Swift Package Manager section. --- _posts/2023-08-29-swift-5.9-released.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 7023d3cab..56bc31f7b 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -119,21 +119,17 @@ The following are some highlights from the changes introduced to the [Swift Pack - Packages can make use of the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. -- The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distribution of custom Swift macros such as [expression macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md). +- The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distributing custom Swift macros as API in a library. -- The new `.embedInCode` resource rule allows embedding the contents of the resource into the executable by generating a byte array, e.g. +- The new `.embedInCode` resource rule allows embedding the contents of the resource into the executable by generating a byte array. - ``` - struct PackageResources { - static let my_resource: [UInt8] = [104,101,108,108,111,32,119,111,114,108,100,10] - } - ``` +- The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network, which allows Linux-oriented packaging and deployment plugins to communicate with Docker within the SwiftPM sandbox. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, the `--allow-network-connections` command-line flag allows network connections for a particular scope. -- The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, there is also a `--allow-network-connections` command-line flag to allow network connections for a particular scope. +- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). -- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM also gains support for signed packages. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. +- SwiftPM now supports signed packages. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. -- A new `swift experimental-sdk` experimental command is now available for managing Swift SDK bundles that follow the format described in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). +- A new `swift sdk` command is now available for installing and removing [Swift SDK bundles](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md#swift-sdk-bundles) on the local filesystem. See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-59) for the complete list of changes. From 03ae3536811c08e82301340c14e3f0c030c38cb4 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 09:37:05 -0700 Subject: [PATCH 27/51] Re-combine the bullet point about SE-0391 and signed packages. Signed packages are not applicable outside of a registry. --- _posts/2023-08-29-swift-5.9-released.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 56bc31f7b..ac4831768 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -125,9 +125,7 @@ The following are some highlights from the changes introduced to the [Swift Pack - The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network, which allows Linux-oriented packaging and deployment plugins to communicate with Docker within the SwiftPM sandbox. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, the `--allow-network-connections` command-line flag allows network connections for a particular scope. -- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). - -- SwiftPM now supports signed packages. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. +- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM now supports signed packages, which a registry may require. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. - A new `swift sdk` command is now available for installing and removing [Swift SDK bundles](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md#swift-sdk-bundles) on the local filesystem. From 4bb86ae077d82da9bb138cbd55ff0719e43c3b14 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 09:40:53 -0700 Subject: [PATCH 28/51] Lift up C++ interop to the top of the Ecosystem section. --- _posts/2023-08-29-swift-5.9-released.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index ac4831768..ff9d52c31 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -113,6 +113,14 @@ Finally, the debug info produced by the Swift compiler is now more precise when ## Ecosystem +### C++ Interoperability + +Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++. You can now use a subset of C++ APIs in Swift and Swift APIs from C++. For information on enabling C++ interoperability and the supported language subset, please refer to the [documentation](/documentation/cxx-interop/). + +C++ interoperability is an actively evolving feature of Swift and developed by the focused [C++ Interoperability Workgroup](/cxx-interop-workgroup/). Certain aspects of the design and functionality might change in future releases of Swift, as the Swift community gathers feedback from real world adoption in mixed Swift and C++ codebases. + +Join the Swift community and the C++ Interoperability Workgroup to provide feedback and help shape the evolution of the feature. + ### Swift Package Manager The following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: @@ -145,14 +153,6 @@ See the [Swift Package Manager changelog](https://github.com/apple/swift-package Over the last year, swift-syntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. In addition, community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! -### C++ Interoperability - -Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++. You can now use a subset of C++ APIs in Swift and Swift APIs from C++. For information on enabling C++ interoperability and the supported language subset, please refer to the [documentation](/documentation/cxx-interop/). - -C++ interoperability is an actively evolving feature of Swift and developed by the focused [C++ Interoperability Workgroup](/cxx-interop-workgroup/). Certain aspects of the design and functionality might change in future releases of Swift, as the Swift community gathers feedback from real world adoption in mixed Swift and C++ codebases. - -Join the Swift community and the C++ Interoperability Workgroup to provide feedback and help shape the evolution of the feature. - ### Server The server workgroup has been busy driving the adoption of Swift concurrency in the server ecosystem, including making use of new 5.9 features such as [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md). The group recently published their [annual update for 2023](/blog/sswg-update-2023/) which goes into details of this work. From b038546ef4189dbe8ce639537afc29cbe18d4d81 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 09:52:18 -0700 Subject: [PATCH 29/51] Update _posts/2023-08-29-swift-5.9-released.md Co-authored-by: Doug Gregor --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index ff9d52c31..e88e8ee28 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -22,7 +22,7 @@ Thank you to everyone in the Swift community who made this release possible. You Swift 5.9 tackles three long-desired features that build upon the fundamental goals of clear and concise code while maintaining safety and efficiency. A new macro system unlocks more expressive power for libraries, parameter packs make overloaded APIs more natural to use, and new ownership features offer more performance control in low-level code. -Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create new language features that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be called with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. +Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create more expressive libraries that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be expanded with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. [Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the optionals wrap different types: From dc5f3f2d98c67c02a3bf5d0b303f30c67632ee40 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 09:55:18 -0700 Subject: [PATCH 30/51] Update _posts/2023-08-29-swift-5.9-released.md Co-authored-by: Adrian Prantl --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index e88e8ee28..ea125c674 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -109,7 +109,7 @@ The `p` and `po` commands now print local variables and properties as fast as th Swift expressions can now refer to generic type parameters. This allows setting a conditional breakpoint in a generic function that only triggers when a type parameter is instantiated with a specific concrete type. -Finally, the debug info produced by the Swift compiler is now more precise when it comes to scoping of local variables. +The debug info produced by the Swift compiler is now more precisely scoping local variables, which makes it less likely to see variables backed by uninitialized memory in the debugger. ## Ecosystem From 7d2f70a6c1e6a8a044161121c7748eb7ca92a3e0 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 10:35:55 -0700 Subject: [PATCH 31/51] Add a code example of Swift-C++ interop. --- _posts/2023-08-29-swift-5.9-released.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index ea125c674..cc0059bb4 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -115,11 +115,31 @@ The debug info produced by the Swift compiler is now more precisely scoping loca ### C++ Interoperability -Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++. You can now use a subset of C++ APIs in Swift and Swift APIs from C++. For information on enabling C++ interoperability and the supported language subset, please refer to the [documentation](/documentation/cxx-interop/). +Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++. You can now use a subset of C++ APIs in Swift and Swift APIs from C++: + +```cpp +// Clang module 'PromptResponder' +#pragma once +#include + +std::vector generatePromptResponse(std::string prompt); +``` + +```swift +import PromptResponder + +let codeLines = generatePromptResponse("Write Swift code that prints hello world") + .map(String.init) + .filter { !$0.isEmpty } + +for line in codeLines { + print(line) +} +``` C++ interoperability is an actively evolving feature of Swift and developed by the focused [C++ Interoperability Workgroup](/cxx-interop-workgroup/). Certain aspects of the design and functionality might change in future releases of Swift, as the Swift community gathers feedback from real world adoption in mixed Swift and C++ codebases. -Join the Swift community and the C++ Interoperability Workgroup to provide feedback and help shape the evolution of the feature. +For information on enabling C++ interoperability and the supported language subset, please refer to the [documentation](/documentation/cxx-interop/). ### Swift Package Manager From 667bbf1e429d0d6d46ae48ebe5e8a854f941d541 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 11:02:13 -0700 Subject: [PATCH 32/51] Show an API before and after parameter packs to demonstrate reducing overloads. --- _posts/2023-08-29-swift-5.9-released.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index cc0059bb4..8404caf80 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -24,7 +24,15 @@ Swift 5.9 tackles three long-desired features that build upon the fundamental go Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create more expressive libraries that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be expanded with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. -[Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over not just any type, but any _number_ of types. For example, this `all(_:)` function lets you check whether any number of `Optional` values are `nil`, even if the optionals wrap different types: +[Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over not just any type, but any _number_ of types. For example, you can write an `all` function to check whether any number of `Optional` values are `nil`, even if the optionals wrap different types. Before Swift 5.9, you needed to write a separate overload for each argument length you wanted to support, with an arbitrary upper limit: + +``` +func all(_ optional: W1?) -> W1? +func all(_ optional1: W1?, optional2: W2?) -> (W1, W2)? +func all(_ optional1: W1?, optional2: W2?, optional3: W3?) -> (W1, W2, W2)? +``` + +With the above `all` API, you can only pass up to 3 arguments, and you'll get an error message if you try to pass more. With parameter packs, you can express this API as a single function that has no upper limit, allowing you to pass any number of arguments: ```swift func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? { @@ -34,9 +42,10 @@ func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapp let optionalInt: Int? = 1 let optionalDouble: Double? = 2.5 let optionalString: String? = nil +let optionalBool: Bool? = true -if let (int, double, string) = all(optionalInt, optionalDouble, optionalString) { - print(int, double, string) +if let (int, double, string, bool) = all(optionalInt, optionalDouble, optionalString, optionalBool) { + print(int, double, string, bool) } else { print("got a nil") From 5f81630559173a99a837f949f3ac07bf44fa6889 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 12:05:27 -0700 Subject: [PATCH 33/51] Editorial changes to the Windows section. --- _posts/2023-08-29-swift-5.9-released.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 8404caf80..903ca2dc9 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -192,13 +192,11 @@ Along with the 5.9 release, the website workgroup has revamped the content on ke ### Windows Platform -The Windows installation received new functionality to inject the module maps via a VFS overlay dynamically rather than needing to modify the Visual Studio installation. This change breaks the dependency order for installation; it is now possible to install either Visual Studio or the Swift toolchain first. This also eliminates the need to repair the installation after an upgrade to Visual Studio. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation lays the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. +The Windows installer now supports installation both before and after Visual Studio installation, and no longer requires repair after a Visual Studio upgrade. This is made possible by new functionality to inject the module maps via a VFS overlay dynamically. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation lays the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. Alongside this improved handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK, enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. -Structured Concurrency is now significantly more stable on Windows. Backtraces are still a work in progress, as the Windows ABI currently prohibits the necessary optimizations required for the proper implementation of the feature. - -Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this significantly improves the developer experience on Windows. +Windows support for Swift 5.9 greatly improves stability and developer experience. Structured Concurrency is now significantly more stable on Windows. Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this significantly improves the developer experience on Windows. Small improvements continue to be made to reduce the size of the toolchain. Although the impact of this is minimal, some of the tools are now smaller in size due to more careful curation of linking. This also reduces the number of artifacts that are contained in a toolchain installation. From 4f13f198b98b2d011305b9b32e29405d4130ecfe Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 14:59:48 -0700 Subject: [PATCH 34/51] More editorial changes for the language section. --- _posts/2023-08-29-swift-5.9-released.md | 49 +++---------------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 903ca2dc9..fbec90873 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -26,7 +26,7 @@ Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/v [Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over not just any type, but any _number_ of types. For example, you can write an `all` function to check whether any number of `Optional` values are `nil`, even if the optionals wrap different types. Before Swift 5.9, you needed to write a separate overload for each argument length you wanted to support, with an arbitrary upper limit: -``` +```swift func all(_ optional: W1?) -> W1? func all(_ optional1: W1?, optional2: W2?) -> (W1, W2)? func all(_ optional1: W1?, optional2: W2?, optional3: W3?) -> (W1, W2, W2)? @@ -35,14 +35,7 @@ func all(_ optional1: W1?, optional2: W2?, optional3: W3?) -> (W1, W With the above `all` API, you can only pass up to 3 arguments, and you'll get an error message if you try to pass more. With parameter packs, you can express this API as a single function that has no upper limit, allowing you to pass any number of arguments: ```swift -func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? { - // Implementation provided below -} - -let optionalInt: Int? = 1 -let optionalDouble: Double? = 2.5 -let optionalString: String? = nil -let optionalBool: Bool? = true +func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? if let (int, double, string, bool) = all(optionalInt, optionalDouble, optionalString, optionalBool) { print(int, double, string, bool) @@ -52,43 +45,11 @@ else { } ``` -
- Implementation of all - -```swift -/// Takes any number of `Optional` arguments and returns `nil` if any of them -/// are `nil`, or a tuple of their values if all of them are non-`nil`. -func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? { - /// Accumulates the results from the `checkNilness(of:)` helper function. - var anyAreNil = false - - // Check if any of the arguments in `each optional` is nil by running this - // `checkNilness(of:)` function on each argument. - func checkNilness(of oneOptional: OneWrapped?) { - if oneOptional == nil { - anyAreNil = true - } - } - repeat checkNilness(of: each optional) - - // Did `checkNilness(of:)` find any nils? If so, return nil early. - if anyAreNil { - return nil - } - - // Otherwise, we can safely force-unwrap all of the arguments and form a tuple - // from the unwrapped values. - return (repeat (each optional)!) -} -``` - -
- The last of these major features helps developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to deinitialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. Finally, [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. -What’s more, these features are all usable today in Swift 5.9, but they are not finished evolving. Each one is too large to fully implement in a single release; we’re excited about what you can already do with them in Swift 5.9, but we’re even more excited to have laid the foundations for better things to come. +These major features are the foundation for further evolution that puts more expressive power and performance control into your hands. We're excited about what you can do with these features in Swift 5.9, and we're working toward a future with a larger suite of variadic generics and ownership features. -In addition to these major features, Swift 5.9 also includes many smaller refinements to the language. The one developers will probably use most often is [`if` and `switch` expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md), which lets you assign the result of a single-expression `if` or `switch` statement to a variable: +Swift 5.9 also includes smaller, quality-of-life changes to the language, including the ability to use [`if` and `switch` as expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md) for variable assignment and return values: ```swift statusBar.text = if !hasConnection { "Disconnected" } @@ -96,7 +57,7 @@ statusBar.text = if !hasConnection { "Disconnected" } else { "Ready" } ``` -Swift 5.9 also adds a [new `package` access level](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) that lets other modules in the same package access APIs, but hides them from code outside the package. It’s great for splitting up large modules into several smaller ones without exposing internals to the package’s clients. +A [new `package` access level](https://github.com/apple/swift-evolution/blob/main/proposals/0386-package-access-modifier.md) lets other modules in the same package access APIs, but hides them from code outside the package. It’s great for splitting up large modules into several smaller ones without exposing internals to the package’s clients. Developers using Swift Concurrency may appreciate the [more convenient `DiscardingTaskGroup` types](https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md) for task groups that don’t generate results and the advanced [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md) feature for controlling the exact environment that an actor is run in. From ccc6457cc8f11b382db1dd58005f80eddea9f997 Mon Sep 17 00:00:00 2001 From: Christopher Thielen <77445+cthielen@users.noreply.github.com> Date: Fri, 15 Sep 2023 15:36:43 -0700 Subject: [PATCH 35/51] Add subheaders to the Language section --- _posts/2023-08-29-swift-5.9-released.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index fbec90873..283b4316c 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -22,8 +22,12 @@ Thank you to everyone in the Swift community who made this release possible. You Swift 5.9 tackles three long-desired features that build upon the fundamental goals of clear and concise code while maintaining safety and efficiency. A new macro system unlocks more expressive power for libraries, parameter packs make overloaded APIs more natural to use, and new ownership features offer more performance control in low-level code. +### Macros + Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create more expressive libraries that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be expanded with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. +### Parameter packs + [Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over not just any type, but any _number_ of types. For example, you can write an `all` function to check whether any number of `Optional` values are `nil`, even if the optionals wrap different types. Before Swift 5.9, you needed to write a separate overload for each argument length you wanted to support, with an arbitrary upper limit: ```swift @@ -45,10 +49,14 @@ else { } ``` +### Ownership + The last of these major features helps developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to deinitialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. Finally, [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. These major features are the foundation for further evolution that puts more expressive power and performance control into your hands. We're excited about what you can do with these features in Swift 5.9, and we're working toward a future with a larger suite of variadic generics and ownership features. +### Additional Features + Swift 5.9 also includes smaller, quality-of-life changes to the language, including the ability to use [`if` and `switch` as expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md) for variable assignment and return values: ```swift From d8941008e3184f5a1966bcba41fb0d63703a3c08 Mon Sep 17 00:00:00 2001 From: Christopher Thielen <77445+cthielen@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:09:55 -0700 Subject: [PATCH 36/51] Add macro examples --- _posts/2023-08-29-swift-5.9-released.md | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 283b4316c..1b7d6c46a 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -20,11 +20,33 @@ Thank you to everyone in the Swift community who made this release possible. You ## Language and Standard Library -Swift 5.9 tackles three long-desired features that build upon the fundamental goals of clear and concise code while maintaining safety and efficiency. A new macro system unlocks more expressive power for libraries, parameter packs make overloaded APIs more natural to use, and new ownership features offer more performance control in low-level code. +Swift 5.9 adds three long-desired features that build upon the fundamental goals of clear and concise code while maintaining safety and efficiency: a new macro system for more expressive libraries, parameter packs to make overloaded APIs natural to use, and new ownership features to offer more performance control in low-level code. ### Macros -Swift now supports [macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md), which allow developers to reduce repetitive boilerplate and create more expressive libraries that can be distributed as a Swift package. Using a macro is easy and natural; macros can either be expanded with the function-like freestanding `#macroName` syntax or attached to declarations with an `@MacroName` attribute, so they work just like built-in language features but can’t be mistaken for normal code. Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the SwiftSyntax library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. +[Macros](https://github.com/apple/swift-evolution/blob/main/visions/macros.md) help developers reduce repetitive boilerplate and create more expressive libraries that can be distributed as a Swift package. + +Using a macro is easy and natural. Macros can either be expanded with a function-like freestanding `#macroName` syntax: + +``` +let _: Font = #fontLiteral(name: "SF Mono", size: 14, weight: .regular) +``` + +or attached to declarations with an `@MacroName` attribute: + +``` +// Move storage from the stored properties into a dictionary, +// turning the stored properties into computed properties. +@DictionaryStorage +struct Point { + var x: Int = 1 + var y: Int = 2 +} +``` + +They work just like built-in language features but can’t be mistaken for normal code. + +Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the [SwiftSyntax](https://github.com/apple/swift-syntax) library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. ### Parameter packs From 5838920a7545404a3079278e7ca668c6cc5d811c Mon Sep 17 00:00:00 2001 From: Christopher Thielen <77445+cthielen@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:13:25 -0700 Subject: [PATCH 37/51] Minor tweaks to the C++ example flow --- _posts/2023-08-29-swift-5.9-released.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 1b7d6c46a..e13295093 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -115,7 +115,9 @@ The debug info produced by the Swift compiler is now more precisely scoping loca ### C++ Interoperability -Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++. You can now use a subset of C++ APIs in Swift and Swift APIs from C++: +Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++ for certain kinds of APIs. + +If you have a C++ function like: ```cpp // Clang module 'PromptResponder' @@ -125,6 +127,8 @@ Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++. Yo std::vector generatePromptResponse(std::string prompt); ``` +you can call it directly from your Swift code: + ```swift import PromptResponder From 6ef669df832711adbcd0f22527be6b151a3c29fe Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 17:02:29 -0700 Subject: [PATCH 38/51] Use consistent formatting for code examples. --- _posts/2023-08-29-swift-5.9-released.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index e13295093..da7c5f7b3 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -28,13 +28,13 @@ Swift 5.9 adds three long-desired features that build upon the fundamental goals Using a macro is easy and natural. Macros can either be expanded with a function-like freestanding `#macroName` syntax: -``` +```swift let _: Font = #fontLiteral(name: "SF Mono", size: 14, weight: .regular) ``` or attached to declarations with an `@MacroName` attribute: -``` +```swift // Move storage from the stored properties into a dictionary, // turning the stored properties into computed properties. @DictionaryStorage @@ -64,10 +64,10 @@ With the above `all` API, you can only pass up to 3 arguments, and you'll get an func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? if let (int, double, string, bool) = all(optionalInt, optionalDouble, optionalString, optionalBool) { - print(int, double, string, bool) + print(int, double, string, bool) } else { - print("got a nil") + print("got a nil") } ``` @@ -137,7 +137,7 @@ let codeLines = generatePromptResponse("Write Swift code that prints hello world .filter { !$0.isEmpty } for line in codeLines { - print(line) + print(line) } ``` From 57a95c8cf28778d10fe3f5865c2750e881840887 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 17:05:51 -0700 Subject: [PATCH 39/51] Add a Next Steps section at the end of the post. --- _posts/2023-08-29-swift-5.9-released.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index da7c5f7b3..abae42248 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -181,10 +181,6 @@ Over the last year, swift-syntax has been a huge success as an open source proje The server workgroup has been busy driving the adoption of Swift concurrency in the server ecosystem, including making use of new 5.9 features such as [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md). The group recently published their [annual update for 2023](/blog/sswg-update-2023/) which goes into details of this work. -### Website - -Along with the 5.9 release, the website workgroup has revamped the content on key pages of [Swift.org](/), including a richer home page, new and detailed getting-started guides, and clearer download and install instructions. - ### Windows Platform The Windows installer now supports installation both before and after Visual Studio installation, and no longer requires repair after a Visual Studio upgrade. This is made possible by new functionality to inject the module maps via a VFS overlay dynamically. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation lays the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. @@ -195,13 +191,19 @@ Windows support for Swift 5.9 greatly improves stability and developer experienc Small improvements continue to be made to reduce the size of the toolchain. Although the impact of this is minimal, some of the tools are now smaller in size due to more careful curation of linking. This also reduces the number of artifacts that are contained in a toolchain installation. -## Downloads +## Next Steps + +### Downloads -## Language Guide +### Website + +[Swift.org](/) has revamped the content on key pages, including a richer home page, new and detailed getting-started guides, and clearer download and install instructions. If you're new to Swift or looking to dive deeper into the language, visit [Swift.org/getting-started](/getting-started/). + +### Language Guide -[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 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). +[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 and is now published with DocC. This is the official Swift guide and a great entry point for learning Swift. The Swift community also maintains a number of [translations](/documentation/#translations). ## Swift Evolution Appendix From 2aa7d5de8865e88e454ea9f315651b6ac9a6b296 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Fri, 15 Sep 2023 17:14:51 -0700 Subject: [PATCH 40/51] Address the outstanding review feedback. --- _posts/2023-08-29-swift-5.9-released.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index abae42248..944d12a61 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -159,7 +159,7 @@ The following are some highlights from the changes introduced to the [Swift Pack - SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM now supports signed packages, which a registry may require. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. -- A new `swift sdk` command is now available for installing and removing [Swift SDK bundles](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md#swift-sdk-bundles) on the local filesystem. +- SwiftPM now supports cross compilation based on [Swift SDK bundles](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md#swift-sdk-bundles). While the feature is still considered experimental, we invite users to try it out and provide feedback. See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-59) for the complete list of changes. @@ -179,7 +179,7 @@ Over the last year, swift-syntax has been a huge success as an open source proje ### Server -The server workgroup has been busy driving the adoption of Swift concurrency in the server ecosystem, including making use of new 5.9 features such as [custom actor executors](https://github.com/apple/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md). The group recently published their [annual update for 2023](/blog/sswg-update-2023/) which goes into details of this work. +Custom actor executors and other features from Swift 5.9 are making their way into the Swift on server ecosystem. The server workgroup also recently published their [annual update for 2023](/blog/sswg-update-2023/), detailing efforts to increase adoption of concurrency within key libraries and more ### Windows Platform @@ -187,7 +187,7 @@ The Windows installer now supports installation both before and after Visual Stu Alongside this improved handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK, enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. -Windows support for Swift 5.9 greatly improves stability and developer experience. Structured Concurrency is now significantly more stable on Windows. Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this significantly improves the developer experience on Windows. +Windows support for Swift 5.9 greatly improves stability and the developer experience. Structured Concurrency is now significantly more stable on Windows, eliminating stack overflows and other execution failures for common patterns including iterating over an `AsyncStream` with many elements. Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this significantly improves the developer experience on Windows. Small improvements continue to be made to reduce the size of the toolchain. Although the impact of this is minimal, some of the tools are now smaller in size due to more careful curation of linking. This also reduces the number of artifacts that are contained in a toolchain installation. From 5d9300e3e0fa9a5e21d2b09561f39104f8b7afc5 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Sat, 16 Sep 2023 09:05:01 +0200 Subject: [PATCH 41/51] add @hborla to list of authors --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 944d12a61..7572e8a91 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -3,7 +3,7 @@ layout: post published: true date: 2023-08-29 15:00:00 title: Swift 5.9 Released -author: [alexandersandberg] +author: [alexandersandberg, hborla] --- Swift 5.9 is now available! 🎉 From b7d6c50299340151d747b80c5b161aca4959e364 Mon Sep 17 00:00:00 2001 From: Christopher Thielen <77445+cthielen@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:00:24 -0700 Subject: [PATCH 42/51] Minor tweaks to Language and Standard Library --- _posts/2023-08-29-swift-5.9-released.md | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 7572e8a91..b0c4b1ab6 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -20,7 +20,9 @@ Thank you to everyone in the Swift community who made this release possible. You ## Language and Standard Library -Swift 5.9 adds three long-desired features that build upon the fundamental goals of clear and concise code while maintaining safety and efficiency: a new macro system for more expressive libraries, parameter packs to make overloaded APIs natural to use, and new ownership features to offer more performance control in low-level code. +Swift's fundamental goal is to encourage code that is clear and concise, while remaining safe and efficient. + +This release adds three long-desired features that further that goal: a new macro system for more expressive libraries, parameter packs to make overloaded APIs natural to use, and new ownership features to offer more performance control in low-level code. ### Macros @@ -46,11 +48,15 @@ struct Point { They work just like built-in language features but can’t be mistaken for normal code. -Implementing a macro uses a powerful and flexible approach: Macros are implemented by writing Swift functions that use the [SwiftSyntax](https://github.com/apple/swift-syntax) library to generate code to insert into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. +Macros are implemented using a powerful and flexible approach: they are simply Swift functions that use the [SwiftSyntax](https://github.com/apple/swift-syntax) library to generate code to be inserted into the source file. + +Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. ### Parameter packs -[Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over not just any type, but any _number_ of types. For example, you can write an `all` function to check whether any number of `Optional` values are `nil`, even if the optionals wrap different types. Before Swift 5.9, you needed to write a separate overload for each argument length you wanted to support, with an arbitrary upper limit: +[Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over an arbitrary number of types. + +For example, without parameter packs, if you wanted to write a function called `all` to check whether any number of `Optional` values are `nil`, you would need to write a separate overload for each argument length you wanted to support, creating an arbitrary upper limit: ```swift func all(_ optional: W1?) -> W1? @@ -58,28 +64,23 @@ func all(_ optional1: W1?, optional2: W2?) -> (W1, W2)? func all(_ optional1: W1?, optional2: W2?, optional3: W3?) -> (W1, W2, W2)? ``` -With the above `all` API, you can only pass up to 3 arguments, and you'll get an error message if you try to pass more. With parameter packs, you can express this API as a single function that has no upper limit, allowing you to pass any number of arguments: +With parameter packs, you can express this API as a single function that has no upper limit, allowing you to pass any number of arguments: ```swift func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? - -if let (int, double, string, bool) = all(optionalInt, optionalDouble, optionalString, optionalBool) { - print(int, double, string, bool) -} -else { - print("got a nil") -} ``` ### Ownership -The last of these major features helps developers fine-tune memory management behavior in performance-critical code. The [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to deinitialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. Finally, [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, represent a specific resource that can’t be meaningfully copied when it’s assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. +Ownership features can help developers fine-tune memory management behavior in performance-critical code. + +The new [`consume` operator](https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md) tells Swift to deinitialize a variable and transfer its contents without copying it. The [`consuming` and `borrowing` parameter modifiers](https://github.com/apple/swift-evolution/blob/main/proposals/0377-parameter-ownership-modifiers.md) provide hints that Swift can use to eliminate unnecessary copying and reference-counting operations when passing a parameter. Finally, [noncopyable structs and enums](https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md) allow you to create types which, like a class, can’t be meaningfully copied when assigned, but like a struct or enum, do not need to be reference-counted because only one storage location can own the instance at a time. -These major features are the foundation for further evolution that puts more expressive power and performance control into your hands. We're excited about what you can do with these features in Swift 5.9, and we're working toward a future with a larger suite of variadic generics and ownership features. +These major features are the foundation for further evolution that puts more expressive power and performance control into your hands. We're excited about what you can do with Swift 5.9, and we're working toward a future with a larger suite of variadic generics and ownership features. ### Additional Features -Swift 5.9 also includes smaller, quality-of-life changes to the language, including the ability to use [`if` and `switch` as expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md) for variable assignment and return values: +Swift 5.9 also includes smaller, quality-of-life changes to the language, like the ability to use [`if` and `switch` as expressions](https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md) for variable assignment and return values: ```swift statusBar.text = if !hasConnection { "Disconnected" } From a7ec23fb97a7b09a1152b6c0371f306e671dd849 Mon Sep 17 00:00:00 2001 From: Christopher Thielen <77445+cthielen@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:44:58 -0700 Subject: [PATCH 43/51] Minor edits to the remaining sections --- _posts/2023-08-29-swift-5.9-released.md | 54 ++++++++++++++++--------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index b0c4b1ab6..a0051380c 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -100,7 +100,7 @@ A full list of Swift 5.9 Evolution proposals can be found at the end of this pos On Linux, the Swift runtime will now catch program crashes and Swift runtime errors and display a backtrace on the program’s output. The backtracer is out-of-process and includes support for `async` functions. -This feature is also available on macOS, but is disabled by default. To enable it, set `SWIFT_BACKTRACE=enable=yes` and sign your program with the `com.apple.security.get-task-allow` entitlement. +This feature is also available on macOS but is disabled by default. To enable it, set `SWIFT_BACKTRACE=enable=yes` and sign your program with the `com.apple.security.get-task-allow` entitlement. ### Debugging @@ -118,7 +118,7 @@ The debug info produced by the Swift compiler is now more precisely scoping loca Swift 5.9 supports bidirectional interoperability with C++ and Objective-C++ for certain kinds of APIs. -If you have a C++ function like: +For example, if you have a C++ function like: ```cpp // Clang module 'PromptResponder' @@ -142,23 +142,25 @@ for line in codeLines { } ``` -C++ interoperability is an actively evolving feature of Swift and developed by the focused [C++ Interoperability Workgroup](/cxx-interop-workgroup/). Certain aspects of the design and functionality might change in future releases of Swift, as the Swift community gathers feedback from real world adoption in mixed Swift and C++ codebases. +C++ interoperability is actively evolving, with some aspects subject to change in future releases as the community gathers feedback from real world adoption in mixed Swift and C++ codebases. For information on enabling C++ interoperability and the supported language subset, please refer to the [documentation](/documentation/cxx-interop/). +Special thanks to the [C++ Interoperability Workgroup](/cxx-interop-workgroup/) for their focus and dedication in supporting this feature. + ### Swift Package Manager -The following are some highlights from the changes introduced to the [Swift Package Manager](https://github.com/apple/swift-package-manager) in Swift 5.9: +The [Swift Package Manager](https://github.com/apple/swift-package-manager) has a number of improvements in Swift 5.9: -- Packages can make use of the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. +- Packages can use the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. - The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distributing custom Swift macros as API in a library. -- The new `.embedInCode` resource rule allows embedding the contents of the resource into the executable by generating a byte array. +- The new `.embedInCode` resource rule allows embedding the contents of a resource into an executable by generating a byte array. -- The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network, which allows Linux-oriented packaging and deployment plugins to communicate with Docker within the SwiftPM sandbox. Permissions can be scoped to Unix domain sockets in general or specifically for Docker, as well as local or remote IP connections which can be limited by port. For non-interactive use cases, the `--allow-network-connections` command-line flag allows network connections for a particular scope. +- The `allowNetworkConnections(scope:reason:)` setting gives a command plugin permissions to access the network. Permissions can be scoped to Unix domain sockets as well as local or remote IP connections, with an option to limit by port. For non-interactive use cases, the `--allow-network-connections` command-line flag allows network connections for a particular scope. -- SwiftPM can now publish to a registry following the publishing spec as defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md). SwiftPM now supports signed packages, which a registry may require. Trust-on-first-use (TOFU) validation checks which previously only included fingerprints (e.g., checksums) has been extended to include signing identities, and it is enforced for source archives as well as package manifests. +- SwiftPM can now publish to a registry following the specification defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md), as well as support signed packages, which may be required by a registry. Trust-on-first-use (TOFU) validation checks can now use signing identities in addition to fingerprints, and are enforced for source archives as well as package manifests. - SwiftPM now supports cross compilation based on [Swift SDK bundles](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md#swift-sdk-bundles). While the feature is still considered experimental, we invite users to try it out and provide feedback. @@ -166,31 +168,39 @@ See the [Swift Package Manager changelog](https://github.com/apple/swift-package ### Swift Syntax -[swift-syntax](https://github.com/apple/swift-syntax) is an essential tool for parsing Swift code, and it helps to power new macro libraries. This year, swift-syntax received a number of major improvements: +[swift-syntax](https://github.com/apple/swift-syntax) is an essential tool for parsing Swift code and helps power the new macro system. This year, swift-syntax received a number of improvements: - Syntax nodes names are more consistent and accurately reflect the Swift language. - Error recovery in the new SwiftParser is greatly improved, leading to more precise error messages for incorrect or missing syntax. -- Incremental parsing is now supported, allowing tools such as an editor to only reparse those parts of a syntax tree that have changed. +- Incremental parsing is now supported, allowing editors and other tools to only reparse those parts of a syntax tree that have changed. -- The documentation of swift-syntax has been greatly expanded and can be viewed at [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax). +- The [documentation](https://swiftpackageindex.com/apple/swift-syntax) of swift-syntax has been greatly expanded. -Over the last year, swift-syntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct open source contributors have contributed to the package accounting for more than 30% of the commits. In addition, community tools like [swift-ast-explorer.com](https://swift-ast-explorer.com) are an invaluable tool to explore and understand the SwiftSyntax tree. Thanks to everyone who contributed! +Over the last year, swift-syntax has been a huge success as an open source project. Since the release of Swift 5.8, more than 30 distinct contributors have worked on the package, accounting for more than 30% of the commits. In addition, the community tool [swift-ast-explorer.com](https://swift-ast-explorer.com) is invaluable in exploring and understanding the SwiftSyntax tree. Thank you to everyone who contributed! ### Server -Custom actor executors and other features from Swift 5.9 are making their way into the Swift on server ecosystem. The server workgroup also recently published their [annual update for 2023](/blog/sswg-update-2023/), detailing efforts to increase adoption of concurrency within key libraries and more +Custom actor executors and other features from Swift 5.9 are making their way into the Swift on server ecosystem. + +The server workgroup also recently published their [annual update for 2023](/blog/sswg-update-2023/), detailing plans to increase adoption of concurrency within key libraries, as well as other efforts. ### Windows Platform -The Windows installer now supports installation both before and after Visual Studio installation, and no longer requires repair after a Visual Studio upgrade. This is made possible by new functionality to inject the module maps via a VFS overlay dynamically. As part of the continued refinement to the installer, initial work towards versioning the toolchain installation lays the foundation for the ability to have multiple parallel toolchain versions installed side-by-side on Windows. +Windows support for Swift 5.9 greatly improves stability and the developer experience. + +The Windows installer now supports installation both before and after Visual Studio installation, and no longer requires repair after a Visual Studio upgrade. Initial work has also begun to enable multiple, parallel toolchains installed side-by-side on Windows. + +The Swift toolchain also added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. -Alongside this improved handling of Visual Studio, the Swift toolchain added new flags (`-windows-sdk-root`, `-windows-sdk-version`, `-visualc-tools-root`, `-visualc-tools-version`) to help control the Windows SDK and Visual C++ tools that it builds against. The Windows SDK (`WinSDK`) module also saw improvements in the coverage of the SDK, enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. +The Windows SDK (`WinSDK`) module saw improvements in coverage, enabling access to a wider set of system APIs. The Visual C++ (`vcruntime`) module was greatly restructured to support C++ interoperability. -Windows support for Swift 5.9 greatly improves stability and the developer experience. Structured Concurrency is now significantly more stable on Windows, eliminating stack overflows and other execution failures for common patterns including iterating over an `AsyncStream` with many elements. Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this significantly improves the developer experience on Windows. +Structured Concurrency is now significantly more stable on Windows, eliminating stack overflows and other execution failures for common patterns such as iterating over an `AsyncStream` with many elements. -Small improvements continue to be made to reduce the size of the toolchain. Although the impact of this is minimal, some of the tools are now smaller in size due to more careful curation of linking. This also reduces the number of artifacts that are contained in a toolchain installation. +Improvements to path handling in the LSP and SPM makes both of these tools more robust on Windows. LLDB also saw initial work towards improving support for Windows, enabling fundamental debugging workflows in LLDB on Windows. While still a work in progress, this will significantly improve the developer experience on Windows. + +Small improvements have also been made to reduce the size of the toolchain on Windows. ## Next Steps @@ -200,11 +210,17 @@ Small improvements continue to be made to reduce the size of the toolchain. Alth ### Website -[Swift.org](/) has revamped the content on key pages, including a richer home page, new and detailed getting-started guides, and clearer download and install instructions. If you're new to Swift or looking to dive deeper into the language, visit [Swift.org/getting-started](/getting-started/). +Swift.org has revamped certain key pages, including [a richer home page](/) and clearer [download and install instructions](/install/). + +If you're new to Swift or looking to dive deeper, check out the updated [Getting Started guides](/getting-started/). ### Language Guide -[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 and is now published with DocC. This is the official Swift guide and a great entry point for learning Swift. The Swift community also maintains a number of [translations](/documentation/#translations). +[The Swift Programming Language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) book has been updated for Swift 5.9 and is now published with DocC. + +This is the official Swift guide and a great entry point for learning Swift. + +The Swift community also maintains a number of [translations](/documentation/#translations). ## Swift Evolution Appendix From 52a6395d8b4fd315cd3add72a956e4d00c890fc6 Mon Sep 17 00:00:00 2001 From: Christopher Thielen Date: Mon, 18 Sep 2023 09:48:32 -0700 Subject: [PATCH 44/51] Clarify macro composition refers to developers writing macros, not compiler engineers implementing the feature --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index a0051380c..d6332e6a5 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -48,7 +48,7 @@ struct Point { They work just like built-in language features but can’t be mistaken for normal code. -Macros are implemented using a powerful and flexible approach: they are simply Swift functions that use the [SwiftSyntax](https://github.com/apple/swift-syntax) library to generate code to be inserted into the source file. +You write macros using a powerful and flexible approach: they are simply Swift functions that use the [SwiftSyntax](https://github.com/apple/swift-syntax) library to generate code to be inserted into the source file. Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. From ff49b011271fe208071a87a58f0a3ba71147e50f Mon Sep 17 00:00:00 2001 From: Christopher Thielen Date: Mon, 18 Sep 2023 09:53:42 -0700 Subject: [PATCH 45/51] Add example of a parameter pack call-site --- _posts/2023-08-29-swift-5.9-released.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index d6332e6a5..b6abefad0 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -70,6 +70,17 @@ With parameter packs, you can express this API as a single function that has no func all(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)? ``` +Calling an API that uses parameter packs is intuitive and requires no extra work: + +```swift +let (int, double, string, bool) = all(optionalInt, optionalDouble, optionalString, optionalBool) { + print(int, double, string, bool) +} +else { + print("got a nil") +} +``` + ### Ownership Ownership features can help developers fine-tune memory management behavior in performance-critical code. From 4eb287aaff30cba8f736138fdbf32b8dec9bc5a1 Mon Sep 17 00:00:00 2001 From: Christopher Thielen Date: Mon, 18 Sep 2023 09:59:19 -0700 Subject: [PATCH 46/51] Add macro examples --- _posts/2023-08-29-swift-5.9-released.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index b6abefad0..a5ef59502 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -52,6 +52,8 @@ You write macros using a powerful and flexible approach: they are simply Swift f Macros make it easy for your library’s users to adopt powerful capabilities that adapt to the code they’re used in, like [the new `Observation` module](https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md), which allows Swift classes to automatically notify other code when their properties change. +The Swift community has been hard at work creating tools and frameworks that build upon macros. For some examples, take a look at [swift-power-assert](https://github.com/kishikawakatsumi/swift-power-assert), [swift-spyable](https://github.com/Matejkob/swift-spyable), [swift-macro-testing](https://github.com/pointfreeco/swift-macro-testing), and [MetaCodable](https://github.com/SwiftyLab/MetaCodable). + ### Parameter packs [Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over an arbitrary number of types. From acd33bbc7b6333340e653031bc0b13502accd806 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Mon, 18 Sep 2023 10:00:29 -0700 Subject: [PATCH 47/51] Update the download section --- _posts/2023-08-29-swift-5.9-released.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index a5ef59502..2a86de745 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -219,7 +219,7 @@ Small improvements have also been made to reduce the size of the toolchain on Wi ### Downloads - +Official binaries are [available for download](https://swift.org/download/) from [Swift.org](http://swift.org/) for macOS, Windows, and Linux. The Swift 5.9 compiler is also included in [Xcode 15](https://apps.apple.com/app/xcode/id497799835). ### Website From e709a82b3c8121cc2cfde23facb2dfcd9f70b7a3 Mon Sep 17 00:00:00 2001 From: Alexander Sandberg Date: Mon, 18 Sep 2023 19:07:11 +0200 Subject: [PATCH 48/51] remove TODO --- _posts/2023-08-29-swift-5.9-released.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 2a86de745..e777117ee 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -16,8 +16,6 @@ Read on for a deep dive into changes to the language, standard library, tooling, 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! - - ## Language and Standard Library Swift's fundamental goal is to encourage code that is clear and concise, while remaining safe and efficient. From 210665e244b71dc463db44f988e6086134260a5c Mon Sep 17 00:00:00 2001 From: Christopher Thielen Date: Mon, 18 Sep 2023 10:08:55 -0700 Subject: [PATCH 49/51] Minor tweaks for readability --- _posts/2023-08-29-swift-5.9-released.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index e777117ee..9fb87f6a2 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -20,7 +20,7 @@ Thank you to everyone in the Swift community who made this release possible. You Swift's fundamental goal is to encourage code that is clear and concise, while remaining safe and efficient. -This release adds three long-desired features that further that goal: a new macro system for more expressive libraries, parameter packs to make overloaded APIs natural to use, and new ownership features to offer more performance control in low-level code. +This release adds three long-desired features that further that goal: a new macro system for more expressive libraries, parameter packs to make overloaded APIs natural to use, and new ownership features to offer more control over performance in low-level code. ### Macros @@ -121,7 +121,7 @@ The `p` and `po` commands now print local variables and properties as fast as th Swift expressions can now refer to generic type parameters. This allows setting a conditional breakpoint in a generic function that only triggers when a type parameter is instantiated with a specific concrete type. -The debug info produced by the Swift compiler is now more precisely scoping local variables, which makes it less likely to see variables backed by uninitialized memory in the debugger. +The debug info produced by the Swift compiler now more precisely scopes local variables, making it less likely to display variables backed by uninitialized memory in the debugger. ## Ecosystem @@ -165,7 +165,7 @@ The [Swift Package Manager](https://github.com/apple/swift-package-manager) has - Packages can use the new `package` access modifier, allowing access of symbols in another target / module within the same package without making them public. SwiftPM automatically sets the new compiler configuration to ensure this feature works out-of-the-box for packages. -- The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distributing custom Swift macros as API in a library. +- The `CompilerPluginSupport` module enables defining macro targets. Macro targets allow authoring and distributing custom Swift macros as APIs in a library. - The new `.embedInCode` resource rule allows embedding the contents of a resource into an executable by generating a byte array. @@ -173,7 +173,7 @@ The [Swift Package Manager](https://github.com/apple/swift-package-manager) has - SwiftPM can now publish to a registry following the specification defined in [SE-0391](https://github.com/apple/swift-evolution/blob/main/proposals/0391-package-registry-publish.md), as well as support signed packages, which may be required by a registry. Trust-on-first-use (TOFU) validation checks can now use signing identities in addition to fingerprints, and are enforced for source archives as well as package manifests. -- SwiftPM now supports cross compilation based on [Swift SDK bundles](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md#swift-sdk-bundles). While the feature is still considered experimental, we invite users to try it out and provide feedback. +- SwiftPM now supports cross compilation based on [the Swift SDK bundle format](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md#swift-sdk-bundles). While the feature is still considered experimental, we invite users to try it out and provide feedback. See the [Swift Package Manager changelog](https://github.com/apple/swift-package-manager/blob/main/CHANGELOG.md#swift-59) for the complete list of changes. @@ -181,7 +181,7 @@ See the [Swift Package Manager changelog](https://github.com/apple/swift-package [swift-syntax](https://github.com/apple/swift-syntax) is an essential tool for parsing Swift code and helps power the new macro system. This year, swift-syntax received a number of improvements: -- Syntax nodes names are more consistent and accurately reflect the Swift language. +- Syntax node names are more consistent and accurately reflect the Swift language. - Error recovery in the new SwiftParser is greatly improved, leading to more precise error messages for incorrect or missing syntax. From a9e7450bd8fbf1b2cf2df3ac70f6dcc41bcd5768 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Mon, 18 Sep 2023 10:43:11 -0700 Subject: [PATCH 50/51] Add a note about which platforms support macros. --- _posts/2023-08-29-swift-5.9-released.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-08-29-swift-5.9-released.md index 9fb87f6a2..babc6cecf 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-08-29-swift-5.9-released.md @@ -52,6 +52,8 @@ Macros make it easy for your library’s users to adopt powerful capabilities th The Swift community has been hard at work creating tools and frameworks that build upon macros. For some examples, take a look at [swift-power-assert](https://github.com/kishikawakatsumi/swift-power-assert), [swift-spyable](https://github.com/Matejkob/swift-spyable), [swift-macro-testing](https://github.com/pointfreeco/swift-macro-testing), and [MetaCodable](https://github.com/SwiftyLab/MetaCodable). +Swift 5.9 supports macros on macOS and Linux, with Windows support coming soon. + ### Parameter packs [Parameter packs](https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md) let you write generic types and functions which work over an arbitrary number of types. From ad1dbdaa4234f874ea56120599625d99762fc5d7 Mon Sep 17 00:00:00 2001 From: Christopher Thielen Date: Mon, 18 Sep 2023 10:48:53 -0700 Subject: [PATCH 51/51] Update post date and time --- ...9-swift-5.9-released.md => 2023-09-18-swift-5.9-released.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename _posts/{2023-08-29-swift-5.9-released.md => 2023-09-18-swift-5.9-released.md} (99%) diff --git a/_posts/2023-08-29-swift-5.9-released.md b/_posts/2023-09-18-swift-5.9-released.md similarity index 99% rename from _posts/2023-08-29-swift-5.9-released.md rename to _posts/2023-09-18-swift-5.9-released.md index babc6cecf..2df36aa16 100644 --- a/_posts/2023-08-29-swift-5.9-released.md +++ b/_posts/2023-09-18-swift-5.9-released.md @@ -1,7 +1,7 @@ --- layout: post published: true -date: 2023-08-29 15:00:00 +date: 2023-09-18 11:00:00 title: Swift 5.9 Released author: [alexandersandberg, hborla] ---