ALAssetsLibrary returning nil for asset that has HEIC URL

525 Views Asked by At

I'm using ALAssetsLibrary to grab an image using its assets library URL. This works fine if the image is a jpeg. However, if I try and grab one that is an HEIF, the call returns nil for the asset. I know that I will need to convert to using PHPhotoLibrary at some point but I'm not quite ready for that yet. Anybody ever seen this problem and/or know how to get around it? Is ALAssetsLibrary just not compatible with HEIF? Here's some code:

let library = ALAssetsLibrary()
// url is set elsewhere
library.asset(for: url, resultBlock: { (asset) in
    // asset is nil here if I pass in an HEIC url, fine if it is JPEG
    // "assets-library://asset/asset.HEIC?id=070FBF77-869D-4B3D-840A-74B4FC65648D&ext=HEIC"
}, failureBlock: { (error) in 
    // Handle error
})
0

There are 0 best solutions below