iCloud + Core Data: Best Practices?

I've looked around on the developer site and on these forums, and from what I've read it looks like Core Data in iCloud is maybe in some sort of transitionary phase (for lack of a better term). Specifically I came across this thread: https://forums.developer.apple.com/message/145557, which talks about ubiquity containers being deprecated, but also states that the APIs being marked deprecated should stay around for a while. I've also seen other threads on these forums with people being confused about this change.


Additionally, there is this document, which references a guide called "iCloud Programming Guide for Core Data," which as far as I can tell has been taken down.


All of this has been kind of confusing to me so I'll just ask this... I have a use case which needs client-side data persistence for offline use, in addition to cloud sync for support of multiple devices. What is the best practice to achieve this currently? Should I use CloudKit's CKRecord (which as I understand, doesn't persist data client-side), the deprecated APIs for Core Data in iCloud, or should my code bridge between these frameworks?


I'm sorry if this question has been answered elsewhere, but I haven't been able to find it if it has. Thanks for any insight.

Accepted Reply

Thanks for all the responses. For my use case, I've decided to go with Realm for local persistence and CloudKit for sync. I'm writing the intermediary code myself.

Replies

CloudKit is an "apples to tangerines" situation, it's not a replacement for iClound sync' records.

The fact that record based sync for iCloud is currently deprecated without a replacement implies that the problem is due to the hard problems not currently having good general solutions. That means that any sort of "best practices" are going to be a case-by-case decision.

Thanks for the reply. I think for the moment I've all but decided to go with Ensembles. In general I try not to use 3rd-party solutions as they're notoriously slow at updating when Apple decides to change things around. But I haven't found a better solution in this case. Open to any suggestions.


Thanks again.

My suggestion is to use the practices that work best for you. Don't waste much time if you can't make something work. There is an awful lot of misinformation being spread. I'm one of those suckers who spent a lot of time trying to get Core Data in iCloud to work before finally giving up. I wouldn't touch either at this point. I don't care what any Apple developer evangelist or blogger says.

Thanks for all the responses. For my use case, I've decided to go with Realm for local persistence and CloudKit for sync. I'm writing the intermediary code myself.

Thanks for posting. I didn't know about Realm. That looks interesting.

Please see my recent inquiry to icloud@apple.com and the response about this below.


My inquiry:

I would like to get sample code with examples of using CloudKit to sink data between a user’s iOS devices while using Core Data for local data storage. The "Example Todo List app" presented at WWDC 2017 in the session entitled "Build Better Apps with CloudKit Dashboard” was described as using Core Data for local data storage. I would greatly appreciate it if you could please send me a link for downloading this sample app and/or other links that might provide sample code that achieves my goal stated above.


Response:

We're working on getting this sample published as Sample Code but it's not quite ready yet. I'll post something in the CloudKit Developer Forums when it's available.

Hello,


When and where could we get the "Todo List" app sample used during the "Build Better Apps with Cloudkit Dashboard" during WWDC17?


Many thanks

hello fivewood,


Any update on thiis one? When do you think this sampel code would be ready and available? Many thanks