Swift 5.9 Released: Macros and C++ Interoperability
Swift 5.9 added an expressive macro system, bidirectional C++ interoperability, parameter packs, ownership features, and if and switch expressions.
Historical Archive. This article documents an event from 2023 and is preserved with its original date for reference. It is not current news, and details may have changed since publication.
What happened
Swift 5.9 was released on September 18, 2023, according to the official announcement on the Swift blog by Alexander Sandberg and Holly Borla. It was a major release that added an expressive macro system, support for integrating Swift into C++ codebases through bidirectional interoperability, parameter packs, an improved debugger, enhanced crash handling and Windows improvements. The Swift 5.9 compiler was also included in Xcode 15.
Macros
The headline feature was a new macro system that helps developers reduce repetitive boilerplate and create more expressive libraries distributable as Swift packages. Macros can be freestanding, expanded with a function-like #macroName syntax, or attached to declarations with an @MacroName attribute. They are written as Swift functions that use the SwiftSyntax library to generate code, and they power new capabilities such as the Observation module, which lets Swift classes automatically notify other code when their properties change.
Parameter packs and ownership
Swift 5.9 added parameter packs, letting developers write generic types and functions that work over an arbitrary number of types, removing the need for many overloads with artificial upper limits. It also introduced ownership features for performance-critical code: a consume operator to transfer a value without copying, consuming and borrowing parameter modifiers to eliminate unnecessary copying and reference counting, and noncopyable structs and enums that cannot be meaningfully copied.
C++ interoperability and quality of life
The release added bidirectional interoperability with C++ and Objective-C++ for certain APIs, letting Swift call C++ functions directly. Smaller improvements included using if and switch as expressions for variable assignment and return values, a new package access level that exposes APIs within a package but hides them from external clients, and Swift Package Manager improvements such as macro targets and publishing to a registry.
Why it mattered
Swift 5.9 was a substantial release that unlocked metaprogramming through macros and opened Swift to large mixed C++ codebases. Parameter packs and ownership features laid foundations for more expressive generics and finer performance control, setting up the safety and platform work that would culminate in Swift 6.
Related on Skillo
See also: Swift 5.5 and async/await, Swift 6's data-race safety.
Sources
Published date reflects the original event date (2023-09-18). This article is original Skillo editorial written from the sources above; facts were verified in September 2026.
Written by
Skillo Staff
0 Comments
Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.