Search code examples
swiftxcodecore-dataicloudcloudkit

CoreData with CloudKit - data not syncing over iCloud


Short question: I have just added CloudKit support to my iOS app and after more than 1 hour nothing happened. Why is that? How much time it takes for iCloud to sync for the first time?

More details:

  • In this article from Apple it says that "Generally, you can expect data to synchronize a local change within about a minute of the change."
  • I have tested CloudKit first with my app's DEV version deployed directly to iPhone and iPad. Syncing started after approximately 20-30 minutes, I think.
  • After this I have added Signing & Capabilities to my main target. I have added the same as for DEV target: iCloud (CloudKit), Background Modes (Remote notifications).
  • After deploying with TestFlight and installing my app on iPhone and iPad, syncing hasn't started after more than 1 hour.
  • To clarify, I am using CloudKit with CoreData. This app that I am testing with TestFlight has some data already. But we are talking about few KB of data to be synced, not even MB.

Is it normal that it takes long time for first iCloud sync? Will it work better later on? What am I missing? Why it didn't start to sync yet? Should I do something more? In code or in CloudKit Dashboard?

EDIT: I have deployed the Development Schema to Production using instructions from this link: Deploying the Schema To deploy a schema to production:

  1. In CloudKit Dashboard, click "Deploy to Production…” button.
  2. Review the changes that are going to be deployed.
  3. Click “Deploy Changes.”

After few minutes one record was synced from iPad to iPhone. After few hours still no sync from iPhone to iPad. I have added new record on iPad, but it didn't sync either.


Solution

  • I just want to add an answer if anyone would have similar problem. What worked for me was signing out from iCloud and signing back in. That's it. My code was OK, it was some problem with iCloud itself.

    It may not work for you, but if your code looks good and you don't have a clue what could be the problem, try to sign out and sign in to the account that has problem with syncing.