Search code examples
iosswiftcore-dataicloudcloudkit

Is Core Data necessary for across device data synchronization with iCloud?


With NSPersistentCloudKitContainer developers can easily enable data synchronization across devices for their App with Core Data stack.

How about for a new app that requires local data persistent (offline data storage on the client) and across device data synchronization (data available on iPhone, iPad, macOS with the same iCloud account sign-in), is Core Data still required? would CloudKit be used as a replacement for Core Data?

Is Core Data a stack can be skipped with CloutKit?


Solution

  • CloudKit is transport only. Core Data is local persistence only. You can use them together, but you can also use them separately. If you want to use CloudKit but not Core Data, you would need to write your own code to handle local persistence. You might, for example, use plain SQLite, with a wrapper like GRDB for local persistence. Or some other way. There are lots of ways to store local data on apps. However, NSPersistentCloudKitContainer is part of Core Data (that’s what makes it work with CloudKit), so you would not use that.