0 Replies
      Latest reply on Feb 14, 2020 8:57 AM by arretevad
      arretevad Level 1 Level 1 (0 points)

        I am using PhotoKit to access Photos in iCloud. For photos who's source is .typeCloudShared, there is no PHAssetResource associated with a PHAsset retrieved from PHFetchResults. This is only true for images/live photos, for videos there are resources available. Snippet below.


        func doPhotos(photos: PHFetchResult) -> Void {
            photos.enumerateObjects({ (asset, idx, _) in
                let resources = PHAssetResource.assetResources(for: asset)
                for resource in resources {
                    // This is never called when asset.sourceType == .typeCloudShared
                    // and asset.mediaType == .image
        func fectchAssets() -> Void {
            var fetchOptions: PHFetchOptions!
            fetchOptions.includeAssetSourceTypes = [.typeUserLibrary, .typeCloudShared, .typeiTunesSynced ]
            let sharedCollection = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .albumCloudShared, options: nil)
            sharedCollection.enumerateObjects( {(collection, idx, stop) in
                let sharedPhotos: PHFetchResult = PHAsset.fetchAssets(in: collection, options: fetchOptions)
                doPhotos(photos: sharedPhotos)


        For other source types, I am able to receive resources. I am able to retreive image data via PHImageManager like below:


        func doPhotos(photos: PHFetchResult) -> Void {
            photos.enumerateObjects({ (asset, idx, _) in
                  let ops = PHImageRequestOptions()
                  ops.isNetworkAccessAllowed = true
                  ops.isSynchronous = true
                  PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize, contentMode: .default, options: ops, resultHandler: {(image, info) -> Void in
                  // This works, image info is valud 


        I am wondering if this behavior is intended. The documentation notes:

        "Assets from shared albums cannot be edited and do not appear in Moments collections."


        I would prefer to work with PHAssetResource as this contains more information and allows for retrieval of original image data (including file format, etc.)


        Any insight woudl be appreciated.