iCloud sync issues using NSPersistentCloudKitContainer for Core Data + CloudKit sync.

I have tried to set up iCloud sync. Despite fully isolating and resetting my development environment, the app fails with:

NSCocoaErrorDomain Code=134060 (PersistentStoreIncompatibleVersionHashError)

What I’ve done:

  • Created a brand new CloudKit container
  • Created a new bundle ID and app target
  • Renamed the Core Data model file itself
  • Set a new model version
  • Used a new .sqlite store path
  • Created a new .entitlements file with the correct container ID
  • Verified that the CloudKit dashboard shows no records
  • Deleted and reinstalled the app on a real device
  • Also tested with “Automatically manage signing” and without

Despite this, the error persists. I am very inexperienced and am not sure what my next step is to even attempt to fix this. Any guidance is apprecitated.

Answered by DTS Engineer in 846443022

PersistentStoreIncompatibleVersionHashError indicates that your current model version is not compatible with the existing Core Data store. You can fix the error by migrating your existing store to the current model version.

If the difference between your current model version and your existing store's model version can be lightweight migrated, you can use the following options to have Core Data automatically migrate the data for you, as described in Set up the Core Data stack:

yourStoreDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
yourStoreDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)

If the difference can't be lightweight migrated, you will need to do a staged or custom migration. To do that, you can start with the following WWDC sessions:

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

PersistentStoreIncompatibleVersionHashError indicates that your current model version is not compatible with the existing Core Data store. You can fix the error by migrating your existing store to the current model version.

If the difference between your current model version and your existing store's model version can be lightweight migrated, you can use the following options to have Core Data automatically migrate the data for you, as described in Set up the Core Data stack:

yourStoreDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
yourStoreDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)

If the difference can't be lightweight migrated, you will need to do a staged or custom migration. To do that, you can start with the following WWDC sessions:

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

iCloud sync issues using NSPersistentCloudKitContainer for Core Data + CloudKit sync.
 
 
Q