1

Accessing CKAsset fileURL property using Swift 3 on a iOS 9 device (or macOS 10.11) for a synced asset on CloudKit crashes with error URL._unconditionallyBridgeFromObjectiveC(NSURL?) -> URL (). when the records are fetched using CKFetchRecordChangesOperation.

I have checked the record on CloudKit Dashboard and it has the asset value set properly. On iOS 10 or macOS 10.12 it works as expected.

The difference between iOS 10 and iOS 9 on CKAsset object is that on iOS 10 my asset has a path value path=~/Library/Caches/CloudKit/.../Assets/..., which is missing from iOS 9 object.

Update: using an Obj-C category over CKAsset to get the image from fileURL fixes the crash, but not the problem, the fileURL is still nil and cannot have the sync working.

Update 2: An Apple engineer confirmed me that it's an iOS 9 SDK bug, and the a workaround to have the fileURL value is to fetch every record individually again, without using operations.

Mihai Panţiru
  • 513
  • 3
  • 16
  • Related: https://stackoverflow.com/questions/41072510/ckasset-in-server-record-contains-no-fileurl-cannot-even-check-for-nil – Bill Dec 16 '18 at 00:33

0 Answers0