SwiftData
Persist your model with a single macro, and query it straight from SwiftUI.
Overview
Add @Model to a Swift class and it becomes something you can save, fetch and sync. No separate schema file, no managed object subclasses.
In SwiftUI, @Query keeps a view in step with the store, and iCloud sync is a configuration option. Underneath it's built on the same proven storage as Core Data.
@Model
Turn a Swift class into a persistent model. The schema comes from your code.
@Query
Fetch, sort and filter right in a SwiftUI view, and stay in sync with the store.
ModelContainer
Configure storage once at the app level, including iCloud sync and migrations.
ModelContext
Insert, delete and save, with autosave and undo support built in.
History
How it grew up.
Introduced
Announced at WWDC23 as the Swift-native way to persist data.
Indexes and custom stores
#Unique, #Index, history tracking and custom data stores.
Model inheritance
Models can subclass other models.
Sections and observers
Sectioned queries, Codable attributes and observers outside views.