Search code examples
swiftxcodemacosxcode10xcode10.3

Is the fetchAssetCollections method deprecated in latest version of Photos library?


I created a command line project in XCode

enter image description here

I think this is a valid code in swift

 let all = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary,  

However when I try it now, the autocomplete does not list fetchAssetCollections as an option.

enter image description here

Similar issue in my constructor

enter image description here

Here is the code fragment

import Foundation
import Photos

class PhotoExplorer {

    init() {
        PHPhotoLibrary.shared().register(self)
    }

    func listAssetsInPhoto() -> PHCollection {
        let fetchOptions = PHFetchOptions()
        PHAssetCollection.fetch //  <- To be complete

    }
}

Here is my build settings

enter image description here

I added import PhotosUI but it does not help.

Did I do something wrong? Is there an API change?


Solution

  • The only way to fix it is by recreating the project.