CoreData with CloudKit - data not syncing over iCloud both ways

I have added CloudKit support to my iOS app and after more than 1 hour nothing happened.
After few hours I got it to the point that:
single records are synced from iPad to iPhone. But still no sync from iPhone to iPad.


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."

More details on what I have done so far:
  • 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.

I have also deployed the Development Schema to Production using instructions from this link:
  1. In CloudKit Dashboard, click "Deploy to Production…” button.

  2. Review the changes that are going to be deployed.

  3. Click “Deploy Changes.”

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?
I experienced exactly the same. Interestingly, in about a month ago, everything sync as expected, it's not until recent few weeks that SwiftUI + CoreData + CloudKit no longer sync even after a long period of time.

I tested both my old projects and Xcode's SwiftUI template(after adding necessary steps like enable CloudKit, etc). I can confirm your findings, that it no longer seems to sync in a reasonable amount of time.
Thanks SeaOverload. But I think it's because I have added CoreData records before activating CloudKit. As written in this article by Grant Grueninger ( I cannot post the link, don't know why)

Your production schema must be correct

In your CloudKit dashboard (with which you should become extremely familiar), you must initialize your development schema and push it to production before you push your app anywhere (even to TestFlight internal testers). If the production schema is incorrect (that is, different than the schema of your app on a device), CloudKit pushes and refreshes can fail, fully or partially (based on what’s different between the schema on the device and the schema in CloudKit) which will make instances of your app appear to silently not sync.

So it seems that I need to:
  • export my data first

  • delete my app from my phone

  • turn on iCloud

  • import data to my app

  • iCloud should sync after this, hopefully

Unless I will find an easier way





CoreData with CloudKit - data not syncing over iCloud both ways
 
 
Q