Problem reading IPTC metadata

I'm trying to read the IPTC metadata for my photos. Specifically, I'm trying to read the keywords. I'm not sure what I'm doing wrong. It works great in the simulator. But as soon as I run it on my phone, I seem to get all the metadata expect the IPTC data. What am I doing wrong? I've tried this on iOS 11 & iOS 12.


I've tried this:


    func displayMetadata(_ url: NSURL) {
        let source: CGImageSource = CGImageSourceCreateWithURL(url, nil)!
        let properties: NSDictionary = CGImageSourceCopyPropertiesAtIndex(source, 0, nil)!
        
        if let iptc = properties[kCGImagePropertyIPTCDictionary as String] {
            print(iptc)
        }
    }


I've also tried this:


    func displayAssetMetadata(_ asset: PHAsset) {
        let options = PHContentEditingInputRequestOptions()
        options.isNetworkAccessAllowed = true //download asset metadata from iCloud if needed

        asset.requestContentEditingInput(with: options) { (contentEditingInput: PHContentEditingInput?, _) -> Void in
            let fullImage = CIImage(contentsOf: contentEditingInput!.fullSizeImageURL!)
            
            if let iptc = fullImage?.properties[kCGImagePropertyIPTCDictionary as String] {
                print(iptc)
            }
        }
    }


Both methods work perfect in the simulator. Neither work on a real device. Why?