According to Apple, adding CloudKit Core Data, was as easy as following three steps.
- Enable iCloud Capacity in Xcode and check CloudKit.
- Add a default iCloud container.
Then everything will work.
It is not true. I did that and that won't work. I even checked the Core Data model with "Used with CloudKit", and there was still an error and CloudKit schema couldn't be created as there was no store for CloudKit.
So I had to create a new project with Core Data and CloudKit enabled at the very beginning.
If you want to know how to convert a Core Data project with CloudKit. See this, Getting Started with Core Data and CloudKit
Create a new project
Create a new project named "Todo List 2" and enable Core Data and CloudKit.
- Add iCloud capability and check CloudKit.
- Then add a default container "iCloud.(You app bundle id)"
This is enough for a macOS app. If yours is an iOS app, you must add
Background Modescapability and check "Remote notifications".
Be careful when you testing your app. The development and release app used different databases in CloudKit. So if you test your app, you must use the development version.