I want to parse all images from my MacOS Photos Library, using PHAsset. However all examples I find are only working for iOS, like the one below, where the last line, which retrieves the assets is not available on macos framework:
NSMutableArray *photos = [[NSMutableArray alloc] init];
PHFetchOptions *allPhotosOptions = [[PHFetchOptions alloc] init];
allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]];
// Below compilation error as fetchAssetsWithMediaType is only on iOS framework
PHFetchResult *allPhotos = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:allPhotosOptions];
What fetchAssets command should I use on MacOS (version 10.13), or is there another way to do so ?
The Photos framework — or at least, the main subset of that framework, which provides apps with read/write access to the entire Photos library — is not available in macOS.
Photos and PhotosUI are present in macOS, but only in support of specific app-extension features:
PHAsset
class.PHAsset
/PHImageManager
system is present. However, it’s still a reduced subset compared to iOS (only what’s needed for a project extension, like fetching the assets in that project), and it’s accessible only to app extensions, not standalone apps.If you’d like the full Photos framework on macOS, your best bet is to file a feature request with Apple.