SwiftData not syncing with iCloud

Hello everyone,

I followed this (https://www.hackingwithswift.com/quick-start/swiftdata/how-to-sync-swiftdata-with-icloud) guide from Paul Hudson on how to sync swiftdata with iCloud. I tried it on my device directly and it worked exactly as I would expect. Now I tried the same version of the app on another device installed through TestFlight external tester group. It no longer works.

When deleting the app, the alert reads "Deleting this app will also delete its data, but any documents or data will be stored in iCloud will not be deleted" so the app should have said something in iCloud. When looking in Settings -> Your Name -> iCloud -> Manage Account Storage, on the working device I can see around 300 KB saved in iCloud, on the other device my app is not listed. Both have a fast and working internet connection, almost fully charged, low data mode turned off, running 17.4.1, Background modes enabled, Mobile data enabled, more than enough unused iCloud storage and plenty of time to sync.

I was streaming the logs from the Cloudkit dashboard but nothing appeared there. The data saved neither syncs to another device of the same apple id nor reappears after app removal.

The model Container is initialized without any configuration, the only relationship is optional and every value has a default value. There is A LOT of log noise when launching the app and I am unable to get any meaningful information from that. I can only get the log from the device where it is working as expected.

I have triple checked that it is exactly the same app version and no debug conditions anywhere. I have absolutely no idea what is causing this.

Thanks for any help :)

Accepted Reply

I got pointed in the right direction.

In the CloudKit Console, click CloudKit Database. Select the correct Container in the top left corner. Click "Deploy Schema Changes" in the bottom left corner and confirm that.

That fixed my issue.

Replies

I got pointed in the right direction.

In the CloudKit Console, click CloudKit Database. Select the correct Container in the top left corner. Click "Deploy Schema Changes" in the bottom left corner and confirm that.

That fixed my issue.