Cannot migrate store in-place: CloudKit integration forbids renaming

Background

Core Data driven app, successfully using NSPersistentCloudKitContainer for some time.

App is written 100% SwiftUI, currently targeting iOS and macOS targets.

Development only, no production release yet.

Error...

... Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." ... reason=Cannot migrate store in-place: CloudKit integration forbids renaming 'foodServes' to 'foodPortions'. Older devices can't process the new relationships.

An unusual problem for me... the renaming occurred between version 7 and version 8 of the Core Data model and this is version 13.

So if I revert back to version 12, there is no issue. It is only when I add the new Entity in model version 13 that the error occurs.

The new entity incudes a relationship back to two other existing entities, but not the Food entity that contains the foodServes -> foodPortions renamingID.

To be clear, the error relates to a renamingID that was implemented in the transition to model version 8. Its only now that I have added a new entity in model version 13 that Xcode is complaining.

I'm not in production, but I still don't want to mess up my extensive test data set and frankly I feel like its good practice to solve these problems as if I were in production.

So what do I do now? Any suggestions?

Accepted Reply

So this wasn't as difficult as it first seemed...

As it happened, all that I was required to do to solve this problem was remove the renaming identifier for all model versions subsequent to my model version 8.

To be clear, I retained the renaming ID in the model version 8 to change the relationship name from 'foodServes' (v7) to 'foodPortions' (v8), then for every model version 9 onwards (to v13), deleted the renaming ID.

New Entity created so I'm happy and no migration errors so CloudKit is happy.

Replies

So this wasn't as difficult as it first seemed...

As it happened, all that I was required to do to solve this problem was remove the renaming identifier for all model versions subsequent to my model version 8.

To be clear, I retained the renaming ID in the model version 8 to change the relationship name from 'foodServes' (v7) to 'foodPortions' (v8), then for every model version 9 onwards (to v13), deleted the renaming ID.

New Entity created so I'm happy and no migration errors so CloudKit is happy.