What's new in Macros
Asked on 07/30/2024
1 search
What's New in Macros
At WWDC 2024, Apple introduced several new features and improvements related to macros, particularly in the context of Swift and Xcode.
Swift Macros
- Previewable Macro: This new macro can be attached to property wrappers like
@State
, allowing you to use them directly within a preview block. This eliminates the need to write wrapper views, simplifying the code and making it easier to see your UI live with minimal lines of code. For example, you can define your state right in the preview's body and attach thepreviewable
macro, which tells the preview system to create a wrapper view behind the scenes (What’s new in Xcode 16). - Preview Modifier: This API makes it easier to share environment or data for previews, reducing duplicate code and enabling the preview system to cache the data (What’s new in Xcode 16).
Swift 6
- Macros in Swift 6: Swift 6 continues to build on the macro system introduced in previous versions, enhancing portability, performance, and the overall developer experience. Macros help reduce repetitive boilerplate code and enable more expressive APIs (What’s new in Swift).
Xcode Previews
- Dynamic Linking Architecture: Xcode Previews now use a new dynamic linking architecture that uses the same build artifacts for previews and when you build and run. This avoids the need to rebuild your project when switching between the two, making for a smoother and more productive workflow. The new
previewable
macro is part of this improvement, allowing dynamic properties like state to be used directly in an Xcode preview (Platforms State of the Union).
Relevant Sessions
These sessions provide a comprehensive overview of the new features and improvements in macros, particularly in the context of Swift and Xcode.

Platforms State of the Union 5-Minute Recap
Watch a quick recap of the newest advancements on Apple platforms.

Build multilingual-ready apps
Ensure your app works properly and effectively for multilingual users. Learn best practices for text input, display, search, and formatting. Get details on typing in multiple languages without switching between keyboards. And find out how the latest advances in the String Catalog can make localization even easier.

What’s new in Swift
Join us for an update on Swift. We’ll briefly go through a history of Swift over the past decade, and show you how the community has grown through workgroups, expanded the package ecosystem, and increased platform support. We’ll introduce you to a new language mode that achieves data-race safety by default, and a language subset that lets you run Swift on highly constrained systems. We’ll also explore some language updates including noncopyable types, typed throws, and improved C++ interoperability.