I’m utilizing CoreData with CloudKit in my iOS app, and I’ve encountered a sequence of points whereas syncing knowledge. The logs present a number of context saves and migration skips, however there’s no clear indication of what is perhaps incorrect. Under is an excerpt of the logs and the related CoreData setup code.
The logs repeatedly present the next:
CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate remoteStoreDidChange:]_block_invoke_2(3216):
- Ignoring distant change notification as a result of it did not change any entities tracked by persistent historical past:
(URL: file:///var/cell/Containers/Knowledge/Software/62AABD0C-972D-4477-BB81-DA2F385B5B43/Library/Applicationpercent20Support/CloudDataModel.sqlite)
And a number of other skipped migrations like:
CoreData: debug: CoreData+CloudKit: -:
Skipping migration for 'ANSCKRECORDMETADATA' as a result of it already has a column named 'ZNEEDSUPLOAD'
Right here is the configuration for my NSPersistentCloudKitContainer in PersistenceController.swift:
lazy var cloudContainer: NSPersistentCloudKitContainer = {
let container = NSPersistentCloudKitContainer(title: "CloudDataModel")
guard let description = container.persistentStoreDescriptions.first else {
fatalError("Didn't retrieve retailer description")
}
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
let containerIdentifier = "iCloud.com.integralstudios.kalo"
description.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: containerIdentifier)
container.loadPersistentStores { description, error in
if let error = error {
print("❌ Unable to load cloud persistent shops: (error)")
}
}
container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
container.viewContext.transactionAuthor = "integralstudios.kalo"
container.viewContext.automaticallyMergesChangesFromParent = true
do {
attempt container.viewContext.setQueryGenerationFrom(.present)
attempt container.initializeCloudKitSchema()
} catch {
print("⚠️ Didn't initialize CloudKit schema: (error)")
}
return container
}()
I additionally use this methodology to avoid wasting knowledge:
func save() {
let localContext = localContainer.viewContext
let cloudContext = cloudContainer.viewContext
if localContext.hasChanges {
do {
attempt localContext.save()
} catch {
print("Error saving native context: (error)")
}
}
if cloudContext.hasChanges {
do {
attempt cloudContext.save()
} catch {
print("Error saving cloud context: (error)")
}
}
}
My very own logging is displaying the cloudkit performance working:
✅ CloudKit schema initialized efficiently
✅ Audio session configured efficiently
✅ Utilizing shared PersistenceController occasion
✅ Verified 6 meals in cloud context
✅ SharedDataManager: UserDefaults created
✅ SharedDataManager: Defaults registered
✅ SharedDataManager: Efficiently verified write entry
Additionally the icloud.developer DB viewer exhibits nothing out of the extraordinary.
- NSCloudKitMirroringDelegate is observing modifications however skipping many notifications.
- It seems that persistent historical past modifications will not be being tracked as anticipated.
- Some migrations are skipped as a consequence of present columns.
Any insights, strategies, or related experiences are tremendously appreciated! Particularly something that helps me dissolve these error calls.