SwiftData updates
Learn about important changes to SwiftData.
Overview
Browse notable changes in SwiftData.
June 2026
Section your query results by creating your query with a macro that takes a
sectionByparameter, as listed on the Additional query macros page.Use types that conform to Codable in a model, including types you don’t control directly, by using the codable option for Schema.Attribute.
Receive real-time updates to models that match specified fetch criteria by using the ResultsObserver type.
Observe remote model changes with the HistoryObserver type.
June 2025
Increase the flexibility of your models by adopting inheritance through the Model() macro.
Gain added flexibility in accessing and sorting transaction history using sortBy in the HistoryDescriptor.
June 2024
Macros
Improve performance of sorts and predicate-based fetches by using the Index(_:) macro to define individual and compound indexes.
Define a unique constraint that includes one or more model attributes using the Unique(_:) macro, enabling SwiftData to regard tuples of attributes as unique.
Specify
nilas a relationship’sinverseto create a unidirectional relationship.
Persistent history
Fetch historical changes for one or more persistent models using the model context’s fetchHistory(_:) method.
Delete stale model history from a persistent store by calling the context’s deleteHistory(_:) method.
Provide an alternate change tracking strategy for your custom persistent store by adopting the HistoryProviding protocol.
Custom persistent stores
Adopt the DataStore protocol (and related protocols) to provide custom storage for your app’s persistent models.
See Also
Technology and frameworks
Accelerate updatesAccessibility updatesActivityKit updatesAdAttributionKit UpdatesApp Clips updatesApp Intents updatesAppKit updatesApple Intelligence updatesAppleMapsServerAPI UpdatesApple Pencil updatesARKit updatesAudio Toolbox updatesAuthenticationServices updatesAVFAudio updatesAVFoundation updates