NSCloudKitMirroringExportRequest issues

I'm attempting to create a Swift/SwiftUI app that will run on iOS/iPadOS that uses CloudKit to syncronize data between devices. I have created the App in Xcode.


In the Apps Signing & Capabilities tab, I have:

- Ensured that the Bundle Identifier is valid

- Added the iCloud capability

- Created the Container and checked it

- Validated that the Container was created in the CloudKit Dashbaord

- Added the Backgrouind Modes capability

- Checked the Remote notifications option


I have modified/validated AppDelegate.swift:

- Validated that it is using NSPersistentCloudKitContainer

- Added container.viewContext.automaticallyMergesChangesFromParent to true

- Added container.viewContext.mergePolicy to NSMergeByPropertyObjectTrumpMergePolicy


When I load the App, I get a series of errors reported related to CloudKit NSCloudKitMirroringExportRequest. These errors are shown below. I am able to create records, but can see they are only stored locally and do not get synced to the CloudKit Dashboard - interestingly enough, the schema has been created in CloudKit Dashboard - so I know some level of connection has been made.


I appreciate any insight that someone can give me to resolve this and allow my data to sync properly.


CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:]_block_invoke(2174): <NSCloudKitMirroringDelegate: 0x600003ef0c60> - Finished automatic export - ExportActivity - with result: <NSCloudKitMirroringResult: 0x60000096cc40> success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request '<NSCloudKitMirroringExportRequest: 0x6000007545a0> B79831CF-9C04-4BB0-90B7-974EB38D2A25' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'." UserInfo={NSLocalizedFailureReason=Request '<NSCloudKitMirroringExportRequest: 0x6000007545a0> B79831CF-9C04-4BB0-90B7-974EB38D2A25' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'.}

CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate finishedAutomatedRequestWithResult:](2119): Finished request '<NSCloudKitMirroringExportRequest: 0x6000007545a0> B79831CF-9C04-4BB0-90B7-974EB38D2A25' with result: <NSCloudKitMirroringResult: 0x60000096cc40> success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request '<NSCloudKitMirroringExportRequest: 0x6000007545a0> B79831CF-9C04-4BB0-90B7-974EB38D2A25' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'." UserInfo={NSLocalizedFailureReason=Request '<NSCloudKitMirroringExportRequest: 0x6000007545a0> B79831CF-9C04-4BB0-90B7-974EB38D2A25' was cancelled because there is already a pending request of type 'NSCloudKitMirroringExportRequest'.}

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _enqueueRequest:]_block_invoke(714): <NSCloudKitMirroringDelegate: 0x600003ef0c60>: enqueuing request: <NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644

CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _enqueueRequest:]_block_invoke_2(724): Failed to enqueue request: <NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644

Error Domain=NSCocoaErrorDomain Code=134417 "Request '<NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'." UserInfo={NSLocalizedFailureReason=Request '<NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'.}

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedImportWithLabel:activity:completionHandler:]_block_invoke(2150): <NSCloudKitMirroringDelegate: 0x600003ef0c60> - Finished automatic import - ImportActivity - with result: <NSCloudKitMirroringResult: 0x60000096f0c0> success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request '<NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'." UserInfo={NSLocalizedFailureReason=Request '<NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'.}

CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate finishedAutomatedRequestWithResult:](2119): Finished request '<NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644' with result: <NSCloudKitMirroringResult: 0x60000096f0c0> success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134417 "Request '<NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'." UserInfo={NSLocalizedFailureReason=Request '<NSCloudKitMirroringImportRequest: 0x6000007a7450> D59C4B33-4075-4A43-AEF0-88EDD466D644' was cancelled because there is already a pending request of type 'NSCloudKitMirroringImportRequest'.}

same issue any update ?

I had the same problem, I've fixed it by disabling publishing of schema intializeCloudKitSchema... in code (as I understand no need to do it all the time) and after - no errors in logs, data appeared on CloudKit console

I had this same problem, but as soon as I uncommented out this code and ran my app, while connected to the Production CloudKit container, it started to work. I thought you only had to do it one time on the Development container and then publish to production in the CloudKit Dashboard. Once I let this code run one time, after that it all started to work.


		do {

			// Use the container to initialize the development schema.

			try container.initializeCloudKitSchema(options: [])

		} catch {

			// Handle any errors.

			print(error)

		}

#endif

I just figured out that this issue can occur when CD_entityName indexes aren't available or deleted (SORTABLE, SEARCHABLE, QUERYABLE). Adding them might help (at least for me).

Same thing here. my debugger console is exploding with these. Tried the things suggested here nothing works. Anyone figured this out?

I'm having this issue as well. I've ensured CD_entityName indexes are a part of each object in the cloudkit console. I've submitted feedback, but has anyone resolved this?

Sync works when I initially install the app on both my devices, but if I remove the app from one and reinstall the error occurs during the syncing process.

NSCloudKitMirroringExportRequest issues
 
 
Q