SwiftData migration error: NSCloudKitMirroringDelegate are not reusable

Hello everyone,

I used SwiftData for v1 of an app and am now trying to make changes to the schema for v2. I created the v2 schema that adds a property to one of the models.

I need to populate the new property so I made a custom migration using didMigrate. However that doesn't seem to matter what I do in the migration because creating the ModelContainer throws an error before didMigrate ever gets called.

The error is:

Unresolved error loading container Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSLocalizedFailureReason=Instances of NSCloudKitMirroringDelegate are not reusable and should have a lifecycle tied to a given instance of NSPersistentStore.}

Higher up in the Xcode output I see things like this (in order):

Request 'D25A8CB8-7341-4FA8-B2F8-3DE2D35B5273' was cancelled because the store was removed from the coordinator.
BUG IN CLIENT OF CLOUDKIT: Registering a handler for a CKScheduler activity identifier that has already been registered
CloudKit setup failed because it couldn't register a handler for the export activity. There is another instance of this persistent store actively syncing with CloudKit in this process.

How can I know from this output what I am doing incorrectly?

Any idea what I should take a look at or try to do differently?

This is a simple app with three models and nothing fancy. The only change in the schema is to add a property. The new property is declared as optional and has an inverse that is also declared as optional.

Thanks for any insight!

Answered by sroy in 854342022

This issue is fixed in the iOS 26 beta. ✅

Accepted Answer

This issue is fixed in the iOS 26 beta. ✅

SwiftData migration error: NSCloudKitMirroringDelegate are not reusable
 
 
Q