How to answer
You don't need to convert the store: SwiftData can open the same SQLite file Core Data writes, so both stacks can run side by side and you migrate screen by screen. The requirements are that both describe the same schema (SwiftData class names match entity names, with the same attribute names, types and optionality), both point at the same store URL, and persistent history tracking is on in the Core Data stack, because SwiftData uses history. Then new features use @Model and @Query, old screens keep their NSFetchedResultsController until you get to them, and the Core Data stack is deleted last.
Key points
- Generate
@Modelclasses from the.xcdatamodeld(Xcode: Editor → Create SwiftData Code…), then review them - Entity name matching: SwiftData's entity name is the class name; rename the Core Data class (e.g.
CDTrip, entity stillTrip) so the two Swift types don't collide - Same store URL:
NSPersistentStoreDescription(url:)andModelConfiguration(url:); for widgets, both in the App Group container - Enable
NSPersistentHistoryTrackingKeyon the Core Data store description - Keep one owner of schema changes at a time; while both stacks are live, change the schema in both together
If they dig deeper
The incremental plan I'd propose: (1) freeze schema changes and generate the @Model layer; (2) add the ModelContainer next to the existing container and ship it read-only on one new screen; (3) move features over one at a time, including writes, and rely on history so each stack sees the other's saves; (4) move background imports to a @ModelActor; (5) once nothing uses Core Data, remove it and define the current schema as your first VersionedSchema, so future changes go through a SchemaMigrationPlan. Check the model for features SwiftData doesn't express the same way before you start: fetched properties, derived attributes, custom NSEntityMigrationPolicy code, and entity inheritance (SwiftData has model inheritance since iOS 26, but check how it maps). If you rely on NSPersistentCloudKitContainer, SwiftData's CloudKit support uses the same mirroring, but test sync on a copy of real data before switching owners.
Common pitfalls
A SwiftData class name that differs from the entity name (SwiftData sees a different entity and the data appears missing). Non-optional Swift properties for attributes that are optional in the model. Two containers pointing at different default URLs (Core Data's NSPersistentContainer.defaultDirectoryURL vs SwiftData's default.store), so each has an empty store. Forgetting history tracking, so one side doesn't see the other's changes. Changing the schema in only one stack while both are live. Converting the store by copying rows into a new SwiftData store, which is slow, risky and unnecessary.
How to use it
import CoreData
import SwiftData
enum SharedStore {
static let url = URL.applicationSupportDirectory.appending(path: "Trips.sqlite")
}
// Core Data side: the entity is still "Trip", but its class is renamed so it
// doesn't collide with the SwiftData model (set Class = CDTrip in the model editor).
@objc(CDTrip)
final class CDTrip: NSManagedObject {
@NSManaged var name: String
@NSManaged var startDate: Date
}
func makeCoreDataContainer() throws -> NSPersistentContainer {
let container = NSPersistentContainer(name: "Trips")
let description = NSPersistentStoreDescription(url: SharedStore.url)
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) // SwiftData uses history
container.persistentStoreDescriptions = [description]
var loadError: (any Error)?
container.loadPersistentStores { _, error in loadError = error } // synchronous by default
if let loadError { throw loadError }
return container
}
// SwiftData side: class name = entity name, same attribute names, types and optionality.
@Model
final class Trip {
var name: String = ""
var startDate: Date = Date.now
init(name: String, startDate: Date) { self.name = name; self.startDate = startDate }
}
func makeModelContainer() throws -> ModelContainer {
try ModelContainer(for: Trip.self, configurations: ModelConfiguration(url: SharedStore.url))
}Verified on macOS with a store created by Core Data (entity Trip, class CDTrip, history on): SwiftData fetched the Core Data row, and a row inserted and saved through SwiftData was then fetched by the Core Data context.
| Phase | Core Data | SwiftData |
|---|---|---|
| 1. Prepare | Rename classes, enable history, freeze schema | Generate @Model types |
| 2. Coexist | Owns existing screens and writes | New read-only screens with @Query |
| 3. Move | Shrinks feature by feature | Takes over writes and @ModelActor imports |
| 4. Finish | Removed | First VersionedSchema = current model |
Best practices
- Migrate incrementally and keep both stacks on one store; never copy data between stores
- Write a test that opens a real fixture store from the current release with both stacks
- Keep the schema identical in both stacks until Core Data is gone
- Move one feature's reads and writes together, so a screen never mixes stacks
- Start versioning with
VersionedSchemaonly after SwiftData owns the schema
Related concepts
- SwiftData vs Core Data, SwiftData Migration, Core Data Migration, Core Data Persistent History, Model Container Configuration, SwiftData Model Inheritance, Persistent Container