Why you should care about CloudKit
If you’ve lived through the last couple iterations of OS X and iOS, you’ve probably had the opportunity to develop a special love/hate relationship with iCloud. Apple’s cloud service suite is made up of many different parts and systems, and while it’s great when it works, it also has a history of being prone to hard-to-diagnose outages and, for developers, obscure error messages.
Apple has worked hard over the last couple years to make iCloud more stable and reliable, and it has largely succeeded, to the point where the grumblings about it have, at least anecdotally, subsided considerably since its introduction.
Despite these improvements, however, iCloud’s file storage offerings have always lacked a number of features that made it less compelling than, say, Dropbox for the needs of many modern apps. For example, while iCloud is mostly free and tightly integrated with both iOS and OS X, it’s limited to sharing information between multiple devices that belong to the same user—pretty restrictive in a world where services supporting multiple users (often on a massive scale) are the focus of some of the most successful apps.
One and many
Thus far, this has left third-party developers who want to build interaction between multiple users with no choice but to come up with their own home-brewed solutions for everything from user authentication to data sync, which are both complex to program and very expensive to maintain—a hard proposition in a market that favors inexpensive or free apps.
These problems have not gone unnoticed in Cupertino, however, and iCloud is getting a major overhaul in iOS 8 and OS X Yosemite. The nebulous Documents & Data “storage solution” will be replaced with iCloud Drive, which more resembles the iTools/MobileMe iDisk of old. Best of all, it’ll give direct access to all of a user’s documents and file right from the Finder.
But that’s not all: The improvements to iCloud also include a behind-the-scenes technology, dubbed CloudKit, that gives developers a brand new bag of tools poised to have a significant impact on the kinds of apps we’re likely to see in the future.
The shared cloud
For starters, CloudKit is all about storage. As before, each third-party app gets access to a “private” data store that is part of a user’s iCloud data allotment; this data is automatically synchronized across multiple devices, and can contain both structured data—like a blog post or invoice—and entire files, like a document or image. Apps like games use this to sync progress between iOS clients, while other apps—including Apple’s Pages, Numbers, and Keynote—store presentations, spreadsheets, and more.
With CloudKit, however, developers also gain access to a new “public” data store that is automatically shared among all users of their apps. The disk space used by the public store is counted towards a different allowance, which Apple allocates on a per-app basis and makes available for free with a set of very generous limits.
To programmers, this new shared data store looks like a combination between a big database and a disk drive that they can control with the same programming tools that they use to build their apps today. The big difference is that the information stored in it can be made available to multiple users, allowing them to collaborate and share information through the cloud—something that iCloud “Classic” was unable to do. For its part, Apple leverages its existing infrastructure to provide all the servers, bandwidth, storage, and maintenance required to run the service—free of charge to everyone involved.
Don't let the term “public” put you off, though—CloudKit doesn't force all the shared data in a big bucket that is automatically visible to everyone who installs a particular app. Instead, developers will be able to protect the information as they see fit, allowing, for example, users from a particular group or organization only to have access to specific content.
Like a server in the app
But that’s not all—developers can also use CloudKit to track changes to the underlying data and generate events when they occur. This makes it easy, for example, to send a remote notification when a message stored in the public database receives a reply, or when an invoice is approved. Again, Apple’s servers take care of all the heavy lifting, eliminating the need for developers to set up their own notification servers—and automatically scaling up to handle loads of any size.
Finally, CloudKit allows third-party apps to piggyback their authentication mechanism on Apple ID, thus making it easy to tell each user apart in a unique way without having to write and maintain a login system—and without forcing users to remember yet another password.
Like everything that Apple does these days, CloudKit is also infused with a deep-seated respect for the user’s privacy. By default, for example, Apple ID will only let developers know if a user is logged in or not, and it’ll assign an identification number that is unique but otherwise anonymous. Only with users’ explicit permission are developers capable of getting access to even a user’s first and last name; every other bit of information attached to an Apple ID identity, including e-mail addresses and physical locations, remains entirely off-limits.
Clear skies ahead
It’s not hard to see that CloudKit greatly simplifies the creation of apps that revolve around multi-user collaboration. Previously, creating a group chat app like Glassboard, or a team-based task management software like Wunderlist, would have required a significant amount of work. A developer would have to set up the server-side infrastructure required to store and synchronize all the data, plus handle the communication between different users. But with CloudKit providing that service, developers can now focus their efforts on building a great user experience right inside their iOS and OS X code.
As an added bonus, Apple has had plenty of time to fine-tune the security that surrounds iCloud, and the company’s current fixation with privacy—a much-welcome fixation, if you ask me—is likely to rub off on third-party developers, leading to more secure apps that are less likely to “accidentally” leak our data all over the Internet.
Of course, the flip side all of this goodness is that CloudKit, which is only available on Apple’s devices and operating systems, contributes to locking both users and developers into the company’s closed ecosystem, making it unsuitable for apps that need to run on multiple platforms. For smaller developers, however, it creates a unique opportunity to bring great software to an enormous audience with virtually no added investments of time or money.