So, I'm building a simple diary app in which the diary pages are saved in Core Data and synced with CloudKit. I have a lot of database operations, which I do asynchronously in the background. For example, when the user writes an entry, I save the diary page every 5 seconds or when the user adds an image to it.
I do not touch anything with CloudKit rather than using an NSPersistentCloudKitContainerand these lines:
cloudKitContainer.automaticallyMergesChangesFromParent = true
guard let containerId = cloudKitContainer.containerIdentifier,
let description = container.persistentStoreDescriptions.first else {
print(#function, "Could not initalizeCloudKitScheme.")
return
}
let options = NSPersistentCloudKitContainerOptions(containerIdentifier: containerId)
description.cloudKitContainerOptions = options
When saving and deleting diary pages I get the following error. The error occurs especially when adding and deleting images, I guess due to their size:
PFCloudKitExporter exportOperationFinished:withSavedRecords:deletedRecordIDs:operationError:]_block_invoke(492): Failed to delete asset file: file:///var/mobile/Containers/Data/Application/D62B434E-A968-423B-8408-9461A97DA8D1/Library/Application%20Support/ckAssetFiles/3F783A57-2038-45E8-8D93-1DD0A7EBD89F.fxd
Error Domain=NSCocoaErrorDomain Code=4 "“3F783A57-2038-45E8-8D93-1DD0A7EBD89F.fxd” couldn’t be removed." UserInfo={NSUserStringVariant=(
Remove
), NSFilePath=/var/mobile/Containers/Data/Application/D62B434E-A968-423B-8408-9461A97DA8D1/Library/Application Support/ckAssetFiles/3F783A57-2038-45E8-8D93-1DD0A7EBD89F.fxd, NSUnderlyingError=0x281995e90 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Can anyone explain how this error can occur, if I am only doing basic operations on my dataset?