End of the road for iCloud CoreData Storage & Sync?

05 Jan, 2017 09:01 PM
 Core Data
iCloud CoreData sync does not work as expected, has always caused issues and the objective was never satisfactorily achieved. By deprecating related symbols, is Apple hinting at end of the road for iCloud CoreData sync?


Core Data is a convenient way to store persistent relational data in iOS apps. It is built on top of sqlite and is a easy framework with plenty of documentation. However a common need in apps is to sync app data between different installations on multiple iOS devices that a user commonly owns, like on an iPhone and iPad, and the same app is installed on both the devices. Apple realised this some time back and allowed syncing of app coredata logs via something called UbiquityStoreManager between devices which use the same iCloud account. This is not a very straight forward solution and there is every chance of data conflicts if same data is modified on two different devices and a sync is triggered. Core Data framework provides for handling this via NSNotifications like NSPersistentStoreDidImportUbiquitousContentChangesNotification, etc.

Data In iCloud Today

While I'm not going into details of how iCloud Coredata sync works, the fact is, it always caused issues and the objective was never satisfactorily achieved. Meanwhile Apple moved on to much more ambitious iCloud data framework called Cloud Kit3. In fact there are three ways to store data on iCloud1 now - 
  1. Key-Value storage
  2. iCloud Documents
  3. Cloud Kit
Apparently iCloud Coredata sync was originally built using (2) above i.e. iCloud Documents. And then Apple became not very keen on maintaining this implementation. It has since -
  1. Deprecated NSPersistentStoreUbiquitousContentNameKey in iOS 10
  2. Nothing in docs2 contain anything useful to help in new implementations of iCloud Coredata sync
  3. iCloud Programming Guide for Core Data - Apparently this link is unlinked in all documentation and specifically can be see in above mentioned doc.

What Next?

Apple probably is asking us to use CloudKit to manage a cloud database and manually handle the sync between local and cloud databases. Pity for those who have gone through the older route. Nevertheless a better step forward, albeit without any clarity, for at-least we know now that the older mechanism expectations were neither met earlier and will not be met in future. Apple has charted a new path for us to take in this case using Cloud Kit.

Hope this helps anyone trying to develop a coredata based app and want to sync that data between devices, to consider the costs of implementing CloudKit separately. 


Footnotes -
  1. About Incorporating iCloud into Your App -  https://developer.apple.com/library/content/documentation/General/Conceptual/iCloudDesignGuide/Chapters/Introduction.html#//apple_ref/doc/uid/TP40012094-CH1-SW1
  2. Designing for Core Data in iCloud -  https://developer.apple.com/library/content/documentation/General/Conceptual/iCloudDesignGuide/Chapters/DesignForCoreDataIniCloud.html#//apple_ref/doc/uid/TP40012094-CH3-SW1
  3. Desiging for Cloud Kit - https://developer.apple.com/library/content/documentation/General/Conceptual/iCloudDesignGuide/DesigningforCloudKit/DesigningforCloudKit.html#//apple_ref/doc/uid/TP40012094-CH9-SW1