CloudKit With CoreData Not Working in Production
Discover why sometimes the sync between CoreData and CloudKit do not work in production but it does while developing.
• 1 min read
Problem
This question bothered me a lot when I first started to use CoreData + CloudKit.
The sync between local and cloud database worked perfectly while developing but as soon as the app was published to the AppStore, it stopped working.
Article
Here you can read my guide on how to use CoreData with SwiftUI.
Solution
Well the answer is pretty simple:
Your CloudKit scheme has to be deployed to production.
And every time you add or change your data models, you have to deploy it to production, so CloudKit knows what your data structure looks like and it will sync with CoreData.
Steps
- Go to the CloudKit console and then select CloudKit Database
- Select your container from the dropdown in the top-left corner
- Make sure your in the Development environment
- In the left sidebar, select Deploy Schema Changes...
- Verify the changes are correct
- Tap Deploy
You're done!
Conclusion
This is a really simple step but it can be overlooked and it drove me crazy, trying to figuring out what was the problem.
I hope this will resolve your issue.
If you have any question about this article, feel free to email me or tweet me @franceleonidev and share your opinion.
Thank you for reading and see you in the next article!
Share this article