Migration of local core data to iCloud core data

I have an app (TapToCount-3W). Currently it is based on local core data. I am planning to migrate the local core data to iCloud data. WIth this migration, I don't want to cause any data lost for current users.

Is there any example project available as a demo? Any advice and best practice for this kind of migration.
You can use NSPersistentCloudKitContainer and point it to the same storage file that you were using before so your users won't lose any data. Please keep in mind that all your data doesn't get uploaded right away, only objects that have changed after migrating to NSPersistentCloudKitContainer are being uploaded.
Your explanation does make sense and gives me clear direction. Thanks!

I'll give it a try.
By the way, for data not changed after migration, will they be eventually updated to cloud, even not right away?
No, unfortunately if you hadn't set true for key NSPersistentHistoryTrackingKey, they will never get it to cloud, they will stay only in your device.

A workaround that I used and worked fine, is to add a property to all entities (I used "cloudReady: Bool", and at the first run of the app, after you adopt NSPersistentCloudKitContainer, change that property to "true" for all entities.

This will force iCloud to sync those objects.
Migration of local core data to iCloud core data
 
 
Q