CloudKit asset download access problem.

My app can insert images as assets to the cloud. When we download them from the dashboard, they are correct.

The app can also retrieve the records and assets. When the retreival is complete the asset.fileURL shows that the asset is downloaded to


~/Library/Caches/CloudKit/com.my-app.etc/abc/Assets/assetName


However when we try to load the data in code with;


let asset = record["image"] as? CKAsset

guard let imageData = NSData(contentsOf: asset!.fileURL) else {

print("Invalid Image! \(record["imageName"]).")

sharedLogger.logText(someText: "bad image from download \(record["imageName"]).\n", type : .error)

continue

}


The NSData() call fails every time. If we access the fileURL with a file call, we get error 513 (access denied). If i go into

the Finder and open the file in the asset cache, the image is correct and opens normally.


The file permissions show "read and write" for the user and "none" for everyone else. The "Caches" folder has the same permissions.


I built a second app with the same cloudkit classes and they work fine in the new app. The problem lies somewhere else. 😟