find any information about Observable macro
Asked on 2025-07-13
1 search
The "observable macro" is a feature introduced in Swift 6.2 that allows developers to opt a class into observation tracking. This is part of the Observation Library, which provides general-purpose APIs for automatically tracking state changes in an object graph. The observable macro is used to broadcast system notifications to registered observers based on a more general observer pattern.
In the session titled "What’s new in Swift" at WWDC 2025, it was explained that you can create an instance of the new observations type with a closure to stream state changes with an async sequence from an observable type. This allows you to observe changes to specific values, such as a player's current state, and receive updates transactionally when observable properties change. This ensures that synchronous updates to multiple properties don't lead to observation updates with the object in an inconsistent state. You can iterate over updated values using a for await
loop.
For more details, you can refer to the session What’s new in Swift (12:31).

What’s new in Swift
Join us for an update on Swift. We’ll talk about workflow improvements that make you more productive, and new and modernized library APIs for fundamental programming tasks. We’ll show examples of Swift adoption throughout more layers of the software stack. Finally, we’ll explore new language features for both improving approachability of concurrency, and achieving peak performance when you need it.

Optimize SwiftUI performance with Instruments
Discover the new SwiftUI instrument. We’ll cover how SwiftUI updates views, how changes in your app’s data affect those updates, and how the new instrument helps you visualize those causes and effects. To get the most out of this session, we recommend being familiar with writing apps in SwiftUI.

SwiftData: Dive into inheritance and schema migration
Discover how to use class inheritance to model your data. Learn how to optimize queries and seamlessly migrate your app’s data to use inheritance. Explore subclassing for building model graphs, crafting efficient fetches and queries, and implementing robust schema migrations. Understand how to use Observable and persistent history for efficient change tracking.