What's the best solution to sync complex user data between iPhone, iPad, macOs devices

I'm currently developing an app which shall share user specific data between all Apple devices the user owns. Currently the data is stored local Core Data DB on each device without synchronization.


I read a lot about CloudKit and also about deprecation of CoreData in iCloud but couldn't identify the most promising solution yet.

What's your experience? What solution are you working on to sync your App on different devices?


Below find a list of possible solutions I'm investigating.

1. CloudKit - Key-value storage
Good to sync single values (e.g. App configurations) in the iCloud and sync over different devices.

2. iCloud Document storage
Stores and sync complete documents via the iCloud. The specific CoreData methods are marked as deprecated. An alternative is not yet mentioned in any apple document or programming guide. All guidelines are already offline.

3. CloudKit

New approach to store data in a public/private database located in the iCloud. Currently no offline cache supported. The device can access the data with a network connection only. Therefore, CloudKit is no real replacement for Core Data for iCloud. But CloudKit supports web based services, so it's possible to show the data on e.g. a homepage.

4. Realm Mobile Database and Realm Object Server
Seems to be an alternative. But own hosting of Realm Object Server needed. How to do that is still unclear for me. The Realm documents just explain how to setup a local server on a macOS/Linux device.


Maybe there are also some frameworks available, connection CloudKit with CoreData (e.g. GitHub projects, etc.).

I'm looking forward for you experience a solutions. Please, also describe the pros and cons.

Accepted Reply

Hi,


Options 1, 2 and 3 all are viable. Apple does not recommend nor can we provide support for 3rd party tools (Realm). As for your other options :


  1. CloudKit - Key-value storage - If the information is App specific and what you are storing is simple enough for a plist file, NSDictionary or any other simple Key/Vaue Pair storage mechanism, this will be the easiest integration for you. There is some minute potential for you to run into race conditions while syncing data across devices, assuming you are editing on multiple devices simultaneously (edge case, I know).
  2. iCloud Document storage - If your information is best represented in a document or your App is working with and/or manipulating documents, this will be your best option. This option will provide callbacks for documents that have been edited to keep things in sync across devices.
  3. CloudKit - If your information is App specific and you want to listen for changes, additions, deletions and so on, CloudKit provides some great options including CKSubscription, which will allow you receive notifications in response to changes. You are also given private and public CKContainer instances to keep sensitive data private and control what is shared with other users.


I assume you've read over the documentation already based on your initial descriptions. Remember, if you have any trouble while implementing the option you choose (assuming its a native solution) you can always open a Technical Support Incident (TSI) and someone will be more than happy to provide support with a specific question.


Here is a link just in case :

Requesting Technical Support - Support - Apple Developer


Hopefully this helps :-)

Replies

I currently writing an app using YapDatabase with the CloudKit extension.

Pros: offline caching.

Cons: up/download progress of CKAssets not available, but can be handled manually.

The best way to handle this scenario is to keep your data locally in Core Data and use CloudKit to sync it across different devices. You will need to write your own code to "glue" Core Data and CloudKit.


The reason why there is no magical solution from Apple that will do that for you is pretty obvious: data structures can be very complex (as well as error and conflict resolution situations) and you need to do some programming yourself to use CloudKit in an effecient and reliable manner.


Certainly, you can download a 3rd party solution that will provide you a database with CloudKit extension of its own. However, think about the huge overhead that you will be adding to your software by doing so. Every data structure is different and unique in a certain way and a 3rd party solution has to provide a solution for every possible edge case in order to work reliably.

Apple's solution is here:

https://developer.apple.com/library/content/documentation/General/Conceptual/iCloudDesignGuide/Chapters/iCloudFundametals.html#//apple_ref/doc/uid/TP40012094-CH6-SW1


If you have lots of data you store it as a document. If you have a little data you store it in the key-value file.

@Morpheus78 Did you end up using Realm? If so, which platform did you end up using for your Realm Object Server?

Hi,


Options 1, 2 and 3 all are viable. Apple does not recommend nor can we provide support for 3rd party tools (Realm). As for your other options :


  1. CloudKit - Key-value storage - If the information is App specific and what you are storing is simple enough for a plist file, NSDictionary or any other simple Key/Vaue Pair storage mechanism, this will be the easiest integration for you. There is some minute potential for you to run into race conditions while syncing data across devices, assuming you are editing on multiple devices simultaneously (edge case, I know).
  2. iCloud Document storage - If your information is best represented in a document or your App is working with and/or manipulating documents, this will be your best option. This option will provide callbacks for documents that have been edited to keep things in sync across devices.
  3. CloudKit - If your information is App specific and you want to listen for changes, additions, deletions and so on, CloudKit provides some great options including CKSubscription, which will allow you receive notifications in response to changes. You are also given private and public CKContainer instances to keep sensitive data private and control what is shared with other users.


I assume you've read over the documentation already based on your initial descriptions. Remember, if you have any trouble while implementing the option you choose (assuming its a native solution) you can always open a Technical Support Incident (TSI) and someone will be more than happy to provide support with a specific question.


Here is a link just in case :

Requesting Technical Support - Support - Apple Developer


Hopefully this helps :-)