In my new SwiftUI app I am using NSPersistentCloudKitContainer API to persist my data and also share it between multiple different devices.
I am always using viewContext to fetch or save records, also my Stack consists of two custom configurations where CloudKit is enabled. One for entities to be stored in the CK public database and one for records in the private database.
This usually works just fine. I can save or delete records on one device and they appear on the other device. However in some situations, usually after I imported data on device A and use the same device to create a new record I get errors like this when saving context:
I have no idea why PersistentCloudKitContainer is not able to merge this as the data for both records is practically the same only the version is updated. Also I am assuming that PersistentCloudKitContainer has an automatic merge policy configured by default which is .
I am using Xcode 12 with deployment target also iOS 14
What did I miss here? Any help is appreciated
I am always using viewContext to fetch or save records, also my Stack consists of two custom configurations where CloudKit is enabled. One for entities to be stored in the CK public database and one for records in the private database.
This usually works just fine. I can save or delete records on one device and they appear on the other device. However in some situations, usually after I imported data on device A and use the same device to create a new record I get errors like this when saving context:
Code Block language Error Domain=NSCocoaErrorDomain Code=133020 "Could not merge changes." UserInfo={conflictList=( "NSMergeConflict (0x28126df40) for NSManagedObject (0x28242eda0) with objectID '0xb76a5d0f17dd5aa9 <x-coredata://FA91F3DE-B508-4842-95E0-EF4346521007/Lift/p11>' with oldVersion = 33 and newVersion = 34 and old object snapshot = {\n id = \"D1E2B253-723C-406C-8566-2307DA2D5C17\";\n name = bench;\n} and new cached row = {\n id = \"D1E2B253-723C-406C-8566-2307DA2D5C17\";\n name = bench;\n}" ), NSExceptionOmitCallstacks=true}
I have no idea why PersistentCloudKitContainer is not able to merge this as the data for both records is practically the same only the version is updated. Also I am assuming that PersistentCloudKitContainer has an automatic merge policy configured by default which is .
I am using Xcode 12 with deployment target also iOS 14
What did I miss here? Any help is appreciated