| license | Apache-2.0 |
| name | ios-core-data-architect |
| description | iOS Core Data architect for persistent storage, CloudKit sync, schema migrations, and SwiftData migration. Activate on: Core Data, NSManagedObject, CloudKit sync, Core Data migration, NSFetchedResultsController, NSPersistentContainer, SwiftData migration path. NOT for: SwiftUI state management (use swiftui-data-flow-expert), server databases (use data-pipeline-engineer), SQLite direct (use mobile-offline-sync-architect). |
| allowed-tools | Read,Write,Edit,Bash(swift:*,xcodebuild:*) |
| category | Mobile Development |
| tags | ["core-data","ios","cloudkit","persistence"] |
| pairs-with | [{"skill":"swiftui-data-flow-expert","reason":"SwiftUI views consume Core Data/SwiftData models"},{"skill":"mobile-offline-sync-architect","reason":"Core Data + CloudKit is an offline sync solution"}] |
iOS Core Data Architect
Expert in Core Data persistence, CloudKit synchronization, schema migrations, and migration paths to SwiftData.
Activation Triggers
Activate on: "Core Data", "NSManagedObject", "CloudKit sync", "Core Data migration", "NSFetchedResultsController", "NSPersistentContainer", "SwiftData migration", "lightweight migration", "Core Data performance"
NOT for: SwiftUI state management → swiftui-data-flow-expert | Server databases → data-pipeline-engineer | SQLite direct → mobile-offline-sync-architect
Quick Start
- Assess project state — new project? Use SwiftData. Existing Core Data? Evaluate migration vs coexistence.
- Design data model — entities, relationships, fetch indexes in the .xcdatamodeld editor
- Configure persistent container — NSPersistentCloudKitContainer for CloudKit sync, NSPersistentContainer for local-only
- Implement migration plan — lightweight (automatic) or heavyweight (mapping model) depending on schema changes
- Optimize fetching — batch size, prefetching, background contexts for heavy operations
Core Capabilities
| Domain | Technologies |
|---|
| Persistence | NSPersistentContainer, NSManagedObjectContext, WAL mode |
| CloudKit | NSPersistentCloudKitContainer, CKRecord zone, conflict resolution |
| Migrations | Lightweight migration, mapping models, progressive migration |
| Performance | NSBatchInsertRequest, NSBatchDeleteRequest, faulting, prefetch |
| SwiftData | Coexistence with Core Data, migration path, @Model from NSManagedObject |
Architecture Patterns
Core Data Stack Setup with CloudKit
class PersistenceController {
static let shared = PersistenceController()
let container: NSPersistentCloudKitContainer
(: ) {
container (name: )
description container.persistentStoreDescriptions.first {
()
}
inMemory {
description.url (fileURLWithPath: )
}
description.cloudKitContainerOptions (
containerIdentifier:
)
description.setOption( ,
forKey: )
description.setOption( ,
forKey: )
container.loadPersistentStores { , error
error { () }
}
container.viewContext.automaticallyMergesChangesFromParent
container.viewContext.mergePolicy
}
() -> {
context container.newBackgroundContext()
context.mergePolicy
context
}
}