NSPersistentCloudKitContainer: Migrating multiple devices with data changes in between

What is the expected / best strategy to migrate a synced Core Data model to a new version?

The issue:

A new app version with a new Core Data model introducing new attributes or entities. DeviceA installs the update and edits data with new values and creates new entities.

DeviceB is still used and downloads these changes. The unknown attributes and entities are ignored, but the HistoryTracking gets updated.

A few days later DeviceB gets the update. The missing attributes and entities are not downloaded, as the history is up to date.

__


The issue exists with iOS 13, I hoped for iOS 14 to introduce a strategy. I tried with the first iOS 14 beta, but it is at least not handled automatically.

From the visible API changes I don't see a way to handle this specifically. Not sure if the talks will reveal anything about it.

Will apply for a lab session and would like to get as much input to prepare before that might take place.


Answered by simonnickel in 678513022

This finally works with iOS 15 beta 1.

As soon as the new model version is installed on the second device, it got all the changes populated in it.

Thanks a lot for fixing it!

I've been facing the same issue on my app and the only solution that I could come up so people don't have to suffer the out of sync issues is version the URL for the Core Data SQL file.

This is terrible because after updating my users don't see their data until is fetched back from iCloud (entire sync because the local DB is new) but at least everything is 100% in sync between devices after updating on every device.


Please file a bug.
FB7716306
Created FB7845430
Tested again with iOS 14 beta 3, not solved yet.
Data inconsistency is a serious problem, hopefully there will be a fix.
Was the problem fixed in iOS 14 beta 4? If the answer is no, which could be the strategy to approach this problem?
Just tested again on iOS 14.4.1 with the same result as described.

The Feedback FB7845430 got marked as potentially fixed in iOS 14, but I updated it with a comment that it's not fixed. I hope someone sees it.
Accepted Answer

This finally works with iOS 15 beta 1.

As soon as the new model version is installed on the second device, it got all the changes populated in it.

Thanks a lot for fixing it!

NSPersistentCloudKitContainer: Migrating multiple devices with data changes in between
 
 
Q