SwiftData is Apple's framework that stores an app's data on the device and, if you want, syncs it through iCloud. Apple introduced it at WWDC23 in June 2023, it runs on iOS 17 and macOS 14 and later, and it's built on Core Data's storage technology.
What SwiftData is
Almost every app needs to remember data between launches, a shopping list, workouts, notes. SwiftData does this without a separate model file or migration mapping. You describe the model as a regular Swift class, and the framework stores the records, tracks changes and tells the screen when to refresh (SwiftData documentation).
Apple introduced SwiftData at WWDC23 in June 2023, in the Meet SwiftData talk. Under the hood it relies on Core Data's proven storage and on Swift's modern concurrency. It also works as a cache for server data, so the app can show something offline.
What it's made of and where it is in Xcode
There's nothing to install beyond import SwiftData. A new project can start with storage turned on, since File › New › Project › App has a Storage field with a SwiftData option (as in Xcode 26). There are four parts.
- @Model turns a class into a stored model, for example
@Model class Trip { var name = "" }. The macro adds PersistentModel and Observable conformance. - ModelContainer owns the store on disk and the schema. You attach it to the app with the modelContainer modifier.
- ModelContext inserts, updates and deletes records and writes changes to disk.
- @Query in a SwiftUI view fetches records that match a condition and refreshes the view when they change.
Field behavior is set with macros. @Attribute has an option that forbids duplicate values, @Relationship(.cascade) deletes related records with the parent, and @Transient keeps a field off the disk.
Versions and what each added
| When | What |
|---|---|
| June 2023, iOS 17 | first release, iOS 17.0, macOS 14.0, watchOS 10.0, tvOS 17.0, visionOS 1.0 |
| June 2024, iOS 18 | the #Index macro and a macro that forbids duplicate field combinations, change history, custom stores through DataStore |
| June 2025, iOS 26 | model inheritance through @Model, sorted history |
| June 2026, iOS 27 | sectioned queries, fields of any Codable type, ResultsObserver and HistoryObserver |
Per SwiftData updates and the SwiftData documentation, checked October 17, 2026.
Inheritance looks like a normal Swift subclass. The base Trip class stays a model, and BusinessTrip and PersonalTrip inherit its fields and add their own. Subclasses are marked @available(iOS 26, *), so an app with an iOS 17 minimum has to check the version. Apple suggests inheritance when you search both shared fields and subclass fields, and an enum is enough for a simple flag (Adopting inheritance in SwiftData).
Syncing through iCloud
SwiftData syncs data across a person's devices through CloudKit on its own once a few conditions are met. For sync it uses the NSPersistentCloudKitContainer class from Core Data. You need two capabilities, iCloud with CloudKit turned on and Background Modes with Remote notifications, and the iCloud capability needs an active Apple Developer account with admin permissions (Apple's documentation).
The model has to suit CloudKit. CloudKit can't enforce no-duplicate constraints, requires every relationship to be optional and doesn't support the deny delete rule. You first create the schema in the development environment and promote it to Production before launch, after which model types can't be deleted and fields can't be changed, only added.
SwiftData and Core Data
Core Data is Apple's older storage framework, and SwiftData is built on its technology. You don't have to rewrite an existing app in one go. Apple's SampleTrips sample comes in three versions, Core Data, SwiftData and a mixed one where the app stays on Core Data while a widget reads the same data through SwiftData from a shared App Group (Adopting SwiftData for a Core Data app). For a new SwiftUI app with an iOS 17 minimum or later, SwiftData is the usual pick, with less code.
Common mistakes
- Turning on iCloud and keeping a no-duplicates rule. CloudKit syncs changes when it sees fit and can't check for duplicates, so the model has to change.
- Required relationships. iCloud servers don't process relationship changes atomically, so CloudKit needs every relationship to be optional.
- Renaming a field after launch. A Production CloudKit schema only grows, and the old field stays forever.
- Forgetting modelContainer. A view with @Query and no container crashes, including in Xcode's preview canvas.
Appto writes your app in SwiftUI in a regular Xcode project, walks through every screen in the simulator itself, fixes what it finds and tells you what to check by hand on your iPhone or through TestFlight. More on the code page.
Questions
What is SwiftData?
Apple's framework for storing app data in Swift. You describe the model as a class with the @Model macro, and the framework handles saving and refreshing screens.
Which iOS version does SwiftData need?
iOS 17.0, macOS 14.0 on the Mac and watchOS 10.0 on the watch. Model inheritance needs iOS 26 (Apple documentation, October 17, 2026).
Should I use SwiftData or Core Data?
For a new app targeting iOS 17 and later, usually SwiftData. An existing Core Data app can move over in parts, as Apple's SampleTrips sample shows.
Does SwiftData sync with iCloud?
Yes, through CloudKit, once you add the iCloud and Background Modes capabilities and make every relationship in the model optional.
What's new in SwiftData in iOS 27?
In June 2026 Apple added sectioned queries, fields of any Codable type, and the ResultsObserver and HistoryObserver types.
Build your own app in Appto
Appto checks the niche on fresh App Store data, designs the screens, writes the code, builds the App Store page and submits to Apple from your account or shows you what to press in App Store Connect. Runs on your own Claude Code or Codex.
Download for Mac