My app uses CoreData & CloudKit for some time. Initially, I was also worried by all the debugger logs, but by now I am ignoring most of them. This is done as follows:
In scheme/Run/Arguments/Arguments Passed On Launch
add and check
-com.apple.CoreData.CloudKitDebug 0
-com.apple.CoreData.Logging.stderr 0
Some comments to you specific logs:
CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:
Apparently only info about the sync setup.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _setUpCloudKitIntegration]:
As reported, the sync setup has been successfully enqueued and will be processed later
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]:
Just an info about the activity of the sync process
CoreData: debug: CoreData+CloudKit: -[PFCloudKitMetadataModelMigrator calculateMigrationStepsWithConnection:
Seems to be an info that CoreDate & CloudKit integration has been done before and that a specific setup for a certain column is not needed.
Since a long time I am ignoring all these logs, and my CoreData & CloudKit works most time without any reported errors.
EDIT:
One can check if there are "real" sync errors: I register for NSPersistentCloudKitContainer.Event
notifications (see the docs) and I am logging sync events with
var currentPersistentCloudKitContainerEvents: [NSPersistentCloudKitContainer.Event] = []
//…
NotificationCenter.default.addObserver(forName: NSPersistentCloudKitContainer.eventChangedNotification, object: nil, queue: .main) { notification in
guard let event = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event else { return }
let eventID = event.identifier
let eventType = event.type
var eventTypeString: String
switch eventType {
case .setup: eventTypeString = "setup "
case .import: eventTypeString = "import"
case .export: eventTypeString = "export"
@unknown default: eventTypeString = "unknown"
}
// Check if the event has already been recorded
let alreadyRecordedEvent = self.currentPersistentCloudKitContainerEvents.first(where: { $0.identifier == eventID} )
var index: Int
if let recordedEvent = alreadyRecordedEvent {
index = self.currentPersistentCloudKitContainerEvents.firstIndex(of: recordedEvent)!
self.currentPersistentCloudKitContainerEvents[index] = event
} else {
index = self.currentPersistentCloudKitContainerEvents.count
self.currentPersistentCloudKitContainerEvents.append(event)
syncLog.log("Started: \(eventTypeString, privacy: .public), ID: \(eventID, privacy: .public), now in progress: \(self.currentPersistentCloudKitContainerEvents.count, privacy: .public)")
}
let recordedEvent = self.currentPersistentCloudKitContainerEvents[index]
if event.endDate != nil {
// The event finished successfully or with error
if recordedEvent.succeeded {
syncLog.log("Succeeded: \(eventTypeString, privacy: .public), ID: \(eventID, privacy: .public), now in progress: \(self.currentPersistentCloudKitContainerEvents.count - 1, privacy: .public)")
} else {
syncLog.error("Did not succeed: \(eventTypeString, privacy: .public), ID: \(eventID, privacy: .public), now in progress: \(self.currentPersistentCloudKitContainerEvents.count - 1, privacy: .public)")
if let error = event.error {
self.handleError(error)
}
}
// Delete the terminated event
self.currentPersistentCloudKitContainerEvents.remove(at: index)
return
}
}
Sync errors are those events that did not succeed. But such event can of course be retried.
A "real" error that I encounter now and then is e.g.
2022-11-21 08:01:51.456355+0100 ShopEasy![61491:2995577] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate resetAfterError:andKeepContainer:]
but CoreData & CloudKit seems to recover.