Did CloudKit Sherlock Ensembles?

Amongst the avalanche of announcements from Apple at WWDC last week, one in particular made my heart sink a little: CloudKit. I'm sure there were more than a few people who thought "There goes Ensembles. Sherlock-ed." And for a little while, I had the same fear, though it soon became clear that CloudKit and Ensembles play different roles when it comes to syncing data.

First, let me say, I think CloudKit is awesome. It probably should have been iCloud 1.0 three years ago. Apple have done a great job, and I fully expect this to succeed. It's particularly useful for apps that not only need cloud storage, but also have social aspects.

CloudKit is basically Apple's take on schema-less cloud storage. Think Parse.com or Azure Mobile Services, and you've pretty well grasp CloudKit. You can store data records in the cloud — not just files — and don't have to write any networking code. You can insert records, form relationships, and perform search queries, much like a cloud variant of Core Data (though not as powerful).

As good as it seems to be, there are limitations. CloudKit is not cross platform, so you can forget Android, and there is no web access to the data. But there should be plenty of smaller companies happy just to 'win' the Apple market, so I think it will get adopted. 

It would be easy to assume that CloudKit 'solves' the sync problem, and makes Ensembles redundant. That's not the case. The two address quite different problems.

CloudKit is a means of storing entities in the cloud — it has no local store or even cache. The good news is that you can choose to use any local store API you like, from keyed archiving to SQLite and Core Data. But if you want to sync, you will have to implement local change tracking. CloudKit will not help with this.

That's what Ensembles is good at. Linking CloudKit to Core Data yourself would certainly be possible, but non-trivial. All indications point to Apple integrating the two in the future, perhaps as early as next WWDC, but even if they do, it will still be a couple of years before existing apps could adopt the technology. 

Ensembles is here now, and I've already started adding a CloudKit backend. Initially, it will not take full advantage of the fine-grained record storage of CloudKit, but will use it as file storage. (Interestingly, this is exactly how iCloud Drive will work.)

Further down the track, it may be possible to extend Ensembles to support the CloudKit record storage more natively, doing away with files. And having added CloudKit support, it would be a slam dunk to include native support for Parse, Azure, and maybe even SQL databases. 

And that there is the trump card of Ensembles: if you are using Core Data, we can add backends that become available to you at virtually no cost. No lock in.

Finally, it's worth pointing out that you could complement Ensembles sync with CloudKit social features. Many apps have private user data that just needs to be synced between devices, but they also need some means of sharing a subset of the data between users. Ensembles can handle the complexities of sync, and you can offload the sharing to CloudKit.