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.

Francesco Leoni

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

  1. Go to the CloudKit console and then select CloudKit Database
  2. Select your container from the dropdown in the top-left corner
  3. Make sure your in the Development environment
  4. In the left sidebar, select Deploy Schema Changes...
  5. Verify the changes are correct
  6. 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

Related articles


Error “Missing package product“ for Swift Packages (SPM)

See how to fix the “Missing package product“ error in Xcode caused by some Swift Packages added through SPM.

2 min read

Q&AErrors

Error “No such file or directory“ for 3rd Party Libraries

See how to fix the “No Such File or Directory“ error in Xcode. It can be frustrating to debug since it can have multiple causes.

1 min read

Q&AErrors

Error “Missing file libarclite“ (Xcode 14.3)

See how to fix the “Missing file libarclite“ error in Xcode. This is due to libraries with minimum deployment target of iOS 11.

1 min read

ErrorsQ&AXcode