SwiftData in appleOS 27
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
Codablein a model, including types you don’t control directly, by using thecodableoption forSchema.Attribute.Receive real-time updates to models that match specified fetch criteria by using the
ResultsObservertype.Observe remote model changes with the
HistoryObservertype.
Discover the latest enhancements to SwiftData. We’ll show you how to persist custom and third-party types using
Codable, and group fetched data into sections in your SwiftUI app. We’ll also explore how to observe data store changes anywhere else usingResultsObserverandHistoryObserver, giving you the flexibility to drive powerful state objects and react precisely to model updates.
Again, there seems to be nothing new in Core Data this year, nor any communication about it. There’s still no interoperability for object IDs. The SwiftData changes seem fine but don’t really address the new framework’s deficiencies relative to Core Data. It seems like there are still basic problems with threading. I just don’t understand how Apple is deciding what to prioritize with this framework.
With SwiftUI, the bones seem questionable, but at least we can see that Apple is full steam ahead, with substantial progress to address limitations and pain points. SwiftData seemed to have better bones and is much less ambitious. Getting it right seemed like just a matter of follow through. But, for some inexplicable reason, it seems to lack the resources and/or urgency to reach its potential. And even though SwiftUI is clearly the chosen one, AppKit remains in development. Meanwhile, Core Data seems to be abandoned, even though SwiftData feels more like a side quest than a genuine attempt to supplant it.
The implicit message, for those who have build the core of their app on top of Apple’s old persistence framework, seems to be that Apple is not looking out for their needs. Core Data will surely get maintenance to the extent that Apple’s own apps need it, but there’s no evidence of a future or even a migration plan. The answer, I guess, is third-party frameworks, but that’s not an easy migration, either, since none is even as close a match as SwiftData.
Add persistence with SwiftData:
Experience SwiftData in action as we add persistence to an existing app. We’ll show you how to define your data models and seamlessly integrate persistent data with SwiftUI. You’ll also learn foundational skills for managing your app’s state using this expressive, declarative API.
Join us online for a deep dive into WWDC26 with Apple engineers and designers to ask questions, get advice, and follow the discussion about the week’s biggest SwiftData announcements.
macOS Golden Gate 27 Beta Release Notes:
Fixed: You might experience a deadlock for
@Querywhen saving aModelContexton a background actor while scheduling new async tasks for aModelActor.
I am so pleased to say these words: IT IS A BIG YEAR FOR SWIFTDATA! 🎉
SwiftData predicates can now work directly with enum values, resulting in cleaner models and simpler query code.
[…]
In iOS 27, Apple introduced support for compound predicates through the
Predicate(all:)andPredicate(any:)initializers, making it easier to build queries dynamically based on user input.
I’m not sure why that took so long.
The framework is gradually moving beyond simple demos and becoming easier to use in larger, more sophisticated projects.
[…]
iOS 27 is the first release where many of the framework’s early rough edges have started to disappear.
Results of my now-yearly check to see if SwiftData’s
ModelActorcontinues to sometimes run code on the main thread: yes it does
Compared with
@Querygaining support for section fetches, andResultsObserverenabling observation of query result changes outside views, I am more interested in@Attribute(.codable). It provides a clearer storage intent and gives developers a way to avoid falling into the black box of composition.Of course,
@Attribute(.codable)is not a silver bullet. It is more like a clearly defined escape hatch SwiftData provides for opaqueCodabletypes: suitable for storing external types that you cannot model yourself, but still genuinely need to persist. The cost is that this content cannot participate in SwiftData’s predicate, sort, or migration awareness. Precisely for this reason, its value lies not in being “more powerful,” but in being “more explicit.”However, SwiftData still does not provide cloud syncing for public / shared data, nor have I seen a clearer signal of performance improvements. These issues will continue to limit its adoption. For many developers, SwiftData this year feels more like it is filling key gaps rather than making a leap significant enough to fundamentally change confidence in it.
Codabletypes in SwiftData seem pretty lame given that SQLite absolutely does have JSON support and does support queries on it?But the funnier thing in the MKMapItem.Identifier example is that
MKMapItem.Identifieris aRawRepresentable==String, so it could actually be stored as aStringin the store.
Previously:
- WWDC 2026 Links
- Batch Delete in SwiftData
- SwiftData’s ModelActor Is Just Weird
- SwiftData Runtime
- Ways SwiftData’s ModelContainer Can Error on Creation
- SwiftData and Core Data at WWDC25
- Returning to Core Data
- Dynamic Swift Predicates in macOS 14 and iOS 17
2 Comments RSS · Twitter · Mastodon
SwiftData's shortcomings drove me to learn GRDB, so for that I'm grateful because I'm enjoying that library.
@Preston Yeah, for a new app I would seriously consider GRDB or something built on top of it like SQLiteData. I just wish these libraries weren’t so big.