Skip to content

Latest commit

 

History

History
123 lines (77 loc) · 9.82 KB

2023-08-29-swift-5.9-released.md

File metadata and controls

123 lines (77 loc) · 9.82 KB
layout published date title author
post
true
2023-08-29 08:00:00 -0700
Swift 5.9 Released!
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 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.

If you’re new to Swift, The Swift Programming Language is the official Swift guide and has been updated for version 5.9. The Swift community maintains a number of 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 below.

Developer Experience

Debugging

In Swift 5.9, we introduced a couple of new features to LLDB 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.

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

Swift Package Manager

Following are some highlights from the changes introduced to the 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.

  • Introducing CompilerPluginSupport module for defining macro targets. Macro targets allow authoring and distribution of custom Swift macros such as expression macros.

  • 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. 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.

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

Swift Syntax

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 swift-syntax has been greatly expanded and can be viewed at swiftpackageindex.com

  • 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 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 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.

C++ interoperability is an actively evolving feature of Swift and developed by the focused C++ Interoperability 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

Downloads

Swift Evolution Appendix

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