cloudkitswiftdata

CloudKit sync issues when not running via Xcode


I have written a macOS app using SwiftData and CloudKit with the intent of sharing data records between devices. If I build and run the app via Xcode, I can create a new record and observe it appearing in the CloudKit database (using the CloudKit console). However, if I locate the app with Product > Show Build Folder in Finder and run it, it fails to sync. Same happens if I go the route of Product > Archive, and distribute the app that way. The only way the database syncs successfully is by launching the app through Xcode.

My CloudKit schema has been deployed to Production. I suspected a problem with my entitlements (see below) but I may well be wrong. Next guess was maybe there's a difference between Debug and Release versions, but I can't see any obvious differences that might cause this issue. Again, I could be wrong.

enter image description here

Any thoughts?


Solution

  • Solved. I was using a VPN, and it appears that iCloud doesn't like VPNs. Anyway, as soon as I switched it off, syncing worked as it should.

    Now, why the Debug version works fine with the VPN turned on while the Release version doesn't is beyond me.