Unable to sync Swift Data with iCloud

Hello, I wanted to sync my Swift Data App with iCloud. I provided default values to all my models, made very relationship between my models optional. Then, at Signing and Capabilities, I finally added Background Modes (and checked Remote notifications) and iCloud (and checked CloudKit and added a container with my bundle id). Now I receive these errors every time I run my app on a device that is connect to iCloud

CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromError:withZoneIDs:forStore:inMonitor:](2620): <NSCloudKitMirroringDelegate: 0x302de80f0> - Failed to recover from error: CKErrorDomain:15
Recovery encountered the following error: (null):0
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](3582): Finished request: <NSCloudKitMirroringDelegateSetupRequest: 0x3031d4460> 53CB1DFC-E589-4945-8AF1-36126756110B with result: <NSCloudKitMirroringResult: 0x301c79320> storeIdentifier: 41F2B808-5C97-44B3-BC28-5534FEBCCF2C success: 0 madeChanges: 0 error: <CKError 0x301c98870: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 044262C6-5136-4989-823C-B0430F7B87DC; container ID = "iCloud.lu.yansoisson.blip-notes"; partial errors: {
	com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x301c7a9a0: "Server Rejected Request" (15/2000); op = 15C2EFE32CB459E1; uuid = 044262C6-5136-4989-823C-B0430F7B87DC>
}>
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](3551): <NSCloudKitMirroringDelegate: 0x302de80f0>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(3567): <NSCloudKitMirroringDelegate: 0x302de80f0>: No more requests to execute.
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2310): <NSCloudKitMirroringDelegate: 0x302de80f0> - Attempting recovery from error: <CKError 0x301c98870: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 044262C6-5136-4989-823C-B0430F7B87DC; container ID = "iCloud.lu.yansoisson.blip-notes"; partial errors: {
	com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x301c7a9a0: "Server Rejected Request" (15/2000); op = 15C2EFE32CB459E1; uuid = 044262C6-5136-4989-823C-B0430F7B87DC>
}>

Here's the debug message that appears first when I start the app

CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: <NSCloudKitMirroringDelegateOptions: 0x3023ec6e0> containerIdentifier:iCloud.lu.yansoisson.blip-notes databaseScope:Private ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x3010e62d0> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x3010e62e0> metricsClient:<PFCloudKitMetricsClient: 0x3010e62f0> metadataPurger:<PFCloudKitMetadataPurger: 0x3010e6300> scheduler:<null> notificationListener:<null> containerOptions:<null> defaultOperationConfiguration:<null> progressProvider:<NSPersistentCloudKitContainer: 0x300785440> test_useLegacySavePolicy:YES archivingUtilities:<PFCloudKitArchivingUtilities: 0x3010e6310> bypassSchedulerActivityForInitialImport:NO bypassDasdRateLimiting:NO activityVouchers:(
)
storeOptions: {
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
    NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x3036f0ea0>";
    NSPersistentHistoryTrackingKey = 1;
    NSPersistentStoreMirroringOptionsKey =     {
        NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x302de80f0>";
    };
    NSPersistentStoreRemoteChangeNotificationOptionKey = 1;
}
CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate observeChangesForStore:inPersistentStoreCoordinator:](427): <NSCloudKitMirroringDelegate: 0x302de80f0>: Observing store: <NSSQLCore: 0x10214ca00> (URL: file:///var/mobile/Containers/Data/Application/780A6276-3BE4-458E-BD2D-EC304B123111/Library/Application%20Support/default.store)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _setUpCloudKitIntegration:](589): <NSCloudKitMirroringDelegate: 0x302de80f0>: Successfully enqueued setup request: <NSCloudKitMirroringDelegateSetupRequest: 0x3031d4460> 53CB1DFC-E589-4945-8AF1-36126756110B
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](3551): <NSCloudKitMirroringDelegate: 0x302de80f0>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(3564): <NSCloudKitMirroringDelegate: 0x302de80f0>: Executing: <NSCloudKitMirroringDelegateSetupRequest: 0x3031d4460> 53CB1DFC-E589-4945-8AF1-36126756110B
CoreData: warning: CoreData+CloudKit: -[PFCloudKitSetupAssistant _checkAccountStatus:]_block_invoke(342): Fetched account info for store 41F2B808-5C97-44B3-BC28-5534FEBCCF2C: <CKAccountInfo: 0x3007bbb80; accountStatus=Available, accountPartition=Prod, deviceToDeviceEncryptionAvailability=(account|device), hasValidCredentials=true, walrus=Enabled, needsToVerifyTerms=false, accountAccessAuthorization=Yes, validationCounter=545>
(null)
CoreData: warning: CoreData+CloudKit: -[PFCloudKitSetupAssistant _checkUserIdentity:]_block_invoke(1446): Fetched user recordID for store 41F2B808-5C97-44B3-BC28-5534FEBCCF2C: <CKRecordID: 0x3012ddbc0; recordName=_e002d189d325132b7dae12ad045e5d76, zoneID=_defaultZone:__defaultOwner__>
(null)

Does anyone know how to solve this issue since I have done everything exactly like mentioned in multiple tutorials and blogs?

Thanks

I'm also having the the exact same issue and get the Server Rejected error while trying to follow Apple's documentation: https://developer.apple.com/documentation/swiftdata/syncing-model-data-across-a-persons-devices

Environment: Xcode 16.1 on MacOS 15.1.

Attempted solutions:

  • I've tried specifying the exact container in the setup:
    ModelConfiguration(schema: schema, isStoredInMemoryOnly: false, cloudKitDatabase: .private("iCloud.com.MyCompany.MyApp"))
    
  • Tried reseting the container environment.
  • Signed out/in of iCloud and restarted computer.
  • Made sure iCloud storage isn't full.
  • Added the CloudKit framework manually to the target.
  • Initialized schema manually as shown in the documentation (this causes a crash with the same error).
  • Tried removing the CloudKit permission from the Certificates, Identifiers & Profiles in my developer account then re-adding it.

None of that has worked, and the CloudKit dashboard doesn't show that any schema was created.

Error:

CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _recoverFromError:withZoneIDs:forStore:inMonitor:](2620): <NSCloudKitMirroringDelegate: 0x600000938000> - Failed to recover from error: CKErrorDomain:15
Recovery encountered the following error: (null):0
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](3582): Finished request: <NSCloudKitMirroringDelegateSetupRequest: 0x60000152c960> 31BF786C-8AD8-48F4-A8A3-328A17A51019 with result: <NSCloudKitMirroringResult: 0x6000038c82a0> storeIdentifier: F3647739-ECCB-4106-AD56-1C4D329C954C success: 0 madeChanges: 0 error: <CKError 0x60000385fae0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 517D53B7-C0E1-4EFB-AEB9-D3339C122DFE; container ID = "iCloud.com.MyCompany.MyApp"; partial errors: {
	com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x6000038d3150: "Server Rejected Request" (15/2000); op = A473375D93C18793; uuid = 517D53B7-C0E1-4EFB-AEB9-D3339C122DFE>
}>

Can you try changing the CloudKit container to a completely different one? I did this and suddenly it started working.

Unable to sync Swift Data with iCloud
 
 
Q