MacOS CloudKit production environment is not working properly

My macOS app is developed using SwfitUI, SwiftData, and CloudKit. In the development environment, CloudKit works well. Locally added models can be quickly viewed in the CloudKit Console. macOS app and iOS app with the same BundleID can also synchronize data normally when developing locally. However, in the production environment, the macOS app cannot synchronize data with iCloud. But iOS app can. The models added in the production environment are only saved locally and cannot be viewed in CloudKit Console Production. I am sure I have configured correctly, container schema changes to deploy to the Production environment. I think there may be a problem with CloudKit in macOS. Please help troubleshoot the problem. I can provide you with any information you need.

    var body: some Scene {
        WindowGroup {
            MainView()
                .frame(minWidth: 640, minHeight: 480)
                .environment(mainViewModel)
        }
        .modelContainer(for: [NoteRecord.self])
    }

I didn't do anything special. I didn’t do anything special. I just used SwiftData hosted by CloudKit.

I have recently been experiencing issues in the Production Environment as well, although I cannot confirm if it is the same situation.

  • My app is Mac only.
  • I am adding iCloud support to an existing app that is already on the Mac App Store. I am testing such support via TestFlight builds.
  • I am not using SwiftData but traditional Core Data with NSPersistentCloudKitContainer.

– When making use of the Production Environment, only partial synchronization took place. This has not been an issue when run in the Development Environment. This occurred multiple times even when testing using accounts with different App IDs.

My only thought was that perhaps iCloud also needed to be enabled as a Capability in Certificates, Identifiers & Profiles. That did not end up being the case. However, I was surprised to see that two iCloud Containers were enabled for this app even though only one was selected for the target in Xcode. After removing the unused container from the list and saving, I performed the following actions on two Macs.

  • I deleted both the local and cloud data (Settings > iCloud > Manager…).
  • I then restarted and gave it another try. Full synchronization occurred, just as it had when using the Development Environment.

From your screenshot, it appears that you have created more than one iCloud Container. However, best I can tell, it cannot be determined from Xcode if both of them will be enabled in Certificates, Identifiers & Profiles.

I need to do a bit more testing before I can confirm that removing the extra container truly was the fix.

MacOS CloudKit production environment is not working properly
 
 
Q