atomicbird / CDMoveDemo

Demo app for backing up and restoring Core Data persistent stores
MIT License
15 stars 2 forks source link

It's not working when enable iCloudKit #1

Closed AlwaysBee closed 1 year ago

AlwaysBee commented 1 year ago

Hi Tom, sorry to bother you again. When I run this demo, every thing worked fine. But when I enabled the iCloud, and add some data, then I can see the same data in iCloud Developer Dashboard.

Then:

  1. Tap the backup button
  2. Delete some data
  3. Tap the restore button, and All deleted data came back.

It looks OK until I relaunch the App, the data I deleted in Step 2 just disappear.

What I can found some useful info from the Debug Area in Xcode are:

CoreData+CloudKit: -[NSCloudKitMirroringDelegate tearDown:]_block_invoke(806): <NSCloudKitMirroringDelegate: 0x28321c540>: Told to tear down with reason: Store Removed

It showed after I tap the restore button.

So I think this will leading the iCloud Syncing stop, then the backup data did not synced to iCloud.

I also tried the migratePersistentStore version, but it has the same issue.

Of cause, I can delete all data of the App store in iCloud before restore to avoid this issue.

atomicbird commented 1 year ago

I haven't tested this project with CloudKit and I have no idea what to expect with CloudKit enabled. I'm sure it complicates things, since it adds a cloud store in addition to the local store, but I don't know how to resolve that.