SwiftData Enhances Queries, Adds Support for External Types and Data Store Observation

The latest update to SwiftData introduces support for Codable types, allowing developers to integrate third-party data models more easily. It also adds a sectionBy parameter for queries and a ResultObserver for improved data monitoring.
Why it matters
These updates improve the developer experience for iOS and macOS app development, simplifying complex data management tasks.
InfoQ Homepage News SwiftData Enhances Queries, Adds Support for External Types and Data Store Observation
Codable attributes solve a limitation in SwiftData when integrating custom or third-party types into a model. Since you do not control a third-party reference type, you cannot mark it with @Model . As a result, it cannot be included directly into a model, because SwiftData is unable to generate a schema for it.
With the new release, though, a third-party type can work seamlessly with SwiftData as long as it conforms to the Codable protocol. In the following example, ExLocation is a value type that we do not control, originating either from the iOS SDK or a third-party library:
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in