mercredi 17 février 2016

Core Data + iCloud: why data disappears after lightweight migration?

I'm doing some tests with Core Data (Sqlite) and iCloud on two real devices using XCode 7.2.1 in debug mode.

I am following these steps:

  1. Install test app on device #1 and add two records
  2. Install test app on device #2 and add two records

    Result: changes synced fine via iCloud, and I get 4 records on the two devices as expected:

"record #1 added from device #1"

"record #2 added from device #1"

"record #1 added from device #2"

"record #2 added from device #2"

  1. Update app on device #1 with a newer data model which triggers lightweight migration as expected.

    Result: after app opened on device #1, it shows 4 records as described above, but then after several moments it shows only 2 records when Core Data transition completes:

"record #1 added from device #1"

"record #2 added from device #1"

  1. Update app on device #2 with the newer data model which triggers lightweight migration.

    Result: after app opened on device #2, it shows 4 records as expected and device #1 also shows the same 4 records after a while, and both devices are fully synced via iCloud and with new data model.

My question: after step 3, why I can't see all records on the first device but only after second device is updated with the new data model? Is this a known issue with test apps, and won't occur on apps distributes on the App Store?

Aucun commentaire:

Enregistrer un commentaire