How to answer
For a new app or feature, SwiftData is the default: the schema lives in Swift, models are Observable, @Query drives SwiftUI, and @ModelActor plus Swift 6 checking keep concurrency honest. Core Data is still the right call when you need what SwiftData doesn't expose: store-level batch inserts and updates, custom merge policies, aggregate fetches, NSFetchedResultsController in UIKit while you support iOS 26 (ResultsObserver is iOS 27+), or CloudKit sharing and public databases. It isn't all-or-nothing: both use the same SQLite store format and can run side by side, so an existing Core Data app can adopt SwiftData screen by screen.
Key points
| Need | SwiftData | Core Data |
|---|---|---|
| Schema | @Model classes in Swift | .xcdatamodeld + NSManagedObject subclasses |
| UI | @Query (sectioned in iOS 27), ResultsObserver (iOS 27+) | @FetchRequest, NSFetchedResultsController |
| Background work | @ModelActor, compile-time isolation | perform, runtime queue confinement |
| Batch operations | delete(model:where:), enumerate | NSBatchInsert/Update/DeleteRequest |
| Conflicts | No merge-policy API | mergePolicy, query generations |
| CloudKit | Private database only | Private, shared and public (NSPersistentCloudKitContainer) |
| Migration | SchemaMigrationPlan | Staged migration, mapping models |
| Uniqueness / indexes / history | #Unique, #Index, fetchHistory | Constraints, fetch indexes, persistent history |
| Inheritance | @Model subclasses (since iOS 26) | Entity inheritance, abstract entities |
If they dig deeper
SwiftData is younger and has sharper runtime edges: predicates that compile but fail in the store (computed properties, conditional casts), and, in my testing on the 27 runtime, .deny rules that didn't block a delete (Apple documents that they should) and R-tree indexes that rejected Double columns. Budget for tests against a real store. Core Data's API is older and less Swift-friendly, but it's 20 years mature, and its runtime behavior is well documented. Whatever you pick, hide it behind a Sendable repository protocol so features (and tests) don't depend on the framework, and switching or mixing later stays cheap. If you need full control of sync or must support non-Apple platforms, consider GRDB/SQLite with CKSyncEngine or your own backend instead.
Common pitfalls
Choosing Core Data for a new SwiftUI app "because SwiftData isn't ready" without naming a missing feature. Choosing SwiftData and discovering late that you need CloudKit sharing. Rewriting a working Core Data stack in one go instead of coexisting. Spreading @Query and ModelContext calls through business logic, which makes any later change of framework expensive.
How to use it
The same small repository on each framework; the app and tests only see NoteStore:
import SwiftData
protocol NoteStore: Sendable { // what the app depends on
func unreadCount() async throws -> Int
func markAllRead() async throws
}
@ModelActor
actor SwiftDataNoteStore: NoteStore {
func unreadCount() throws -> Int {
try modelContext.fetchCount(FetchDescriptor<Note>(predicate: #Predicate { !$0.isRead }))
}
func markAllRead() throws {
try modelContext.enumerate(FetchDescriptor<Note>(predicate: #Predicate { !$0.isRead })) {
$0.isRead = true // loads objects in batches
}
try modelContext.save()
}
}import CoreData
final class CoreDataNoteStore: NoteStore {
let container: NSPersistentContainer // Sendable
init(container: NSPersistentContainer) { self.container = container }
func unreadCount() async throws -> Int {
let context = container.newBackgroundContext()
return try await context.perform {
let request = NSFetchRequest<NSManagedObject>(entityName: "Note")
request.predicate = NSPredicate(format: "isRead == NO")
return try context.count(for: request)
}
}
func markAllRead() async throws {
let context = container.newBackgroundContext()
try await context.perform {
let update = NSBatchUpdateRequest(entityName: "Note") // store-level, no objects loaded
update.predicate = NSPredicate(format: "isRead == NO")
update.propertiesToUpdate = ["isRead": true]
_ = try context.execute(update)
}
}
}Note the trade-off in markAllRead: SwiftData walks the objects in batches, while Core Data's NSBatchUpdateRequest changes rows in SQLite without loading them (fast, but in-memory contexts must be told to refresh).
Best practices
- Default to SwiftData for new code, and write down the specific feature if you pick Core Data
- Check the deal-breakers early: CloudKit sharing or public data, very large batch updates, custom conflict handling
- Coexist rather than rewrite: share the store, enable history, migrate feature by feature
- Abstract persistence behind protocols injected through
init - Test both stacks with in-memory stores and real migration fixtures
Related concepts
- Migrating from Core Data to SwiftData, SwiftData Basics, Core Data, SwiftData and CloudKit, SwiftData Custom Data Store, Core Data in Swift 6, SQLite on iOS, Realm