Accessing "From my mac" in PhotoKit

Is it possible to access "From my mac" photos/PHAssetCollection through PhotoKit in iOS?

"From my mac" photos/videos are media synced from a mac where iCloud Photos are turned off on the iOS device, like what we did in the ole' days before iCloud Photos.

I have set up an iOS device with "From my mac" albums present in Photos.app, but in my own app I don't seem to be able to access those collections/photos through PhotoKit using all the defined PHAssetCollectionTypes.

Are these directly synced photos simply not available through PhotoKit and you would have to revert to the deprecated ALAssetLibrary?

Most asset and assetcollection searches are pre-configured with default search options to only include user-library content, however you can fetch assets and asset collections from synced (from my mac) and cloud shared sources.

To fetch "from my mac" and/or "shared album" assets you typically need to pass in PHFetchOptions configured to includeAssetSourceTypes with the desired combination of PHAssetSourceTypeiTunesSynced and/or PHAssetSourceTypeCloudShared

To fetch synced albums, use the PHAssetCollection fetchAssetCollectionsWithType:subtype:options: with the PHAssetCollectionSubtypeAlbumSyncedAlbum like this:

    PHFetchResult<PHAssetCollection *> *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumSyncedAlbum options:nil];

Thank you anonymous Framework Engineer, it worked.

I had erroneously thought that querying for .album and subtype .any like so:

let albums = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: nil)

would fetch for all albums regardless of subtype, including the synced albums, but alas not, you have to query for them specifically.

Is this also the case for all the other PHAssetCollectionSubtype subtypes?

I sync photos locally via Finder between Photos on macOS and Photos on iOS. I do not use iCloud for Photos, but only other data.

I want to give some apps full access to my photo library. There’s a way to do this in iOS settings and via the prompt in an app, but the full access does not give permission to synced photos. Therefore currently with my new iPhone my library is empty in all third party apps besides a handful of new photos that I shot with the new iPhone. I can’t access my synced photos.

For example, when I use the following sample code:

https://developer.apple.com/documentation/photokit/browsing_and_modifying_photo_albums

And make adjustments that were posted here then I can fetch synced albums and their names, but not a single asset of an synced album asset collection.

If I change the permission in the iOS settings from full access to limited access and individually select photos from the synced album it works. But this doesn't scale for the entire photo library.

I expect full access to be full access to all photos and not just photos from iCloud library or photos that were shot on this device.

Another misleading thing is that in the iOS settings app under privacy -> photos there’s a list section „full access“, which shows photos synced from my mac that won’t be accessible in reality due to the bug. Below the text label says „11 photos, 3 videos“, which is correct and what's really accessible. My library has around 27k assets and besides those 14 assets they’re synced from macOS.

I filed two feedbacks:

FB13364538 FB13364521

The bug you describe kai_ is perhaps not a bug, but how Apple intended it to work and is why I was confused about how to fetch synced (non-iCloud) photos in my app. When querying the photo library for photos on the top level, you only get the iCloud photos. It requires querying specifically for synced photos in order to get them.

I had assumed that synced photos was a subset of querying for all photos, but no it doesn't work that way and it's not clear at all in the iOS documentation.

So Apple will likely reject your feedback and you need to file feedback with the app developers of the apps that are not working for you and refer to this thread - this is what prompted me to start this thread because one of my customers had the same issue as you and now I have fixed it by querying for iTunes/mac synced photos specifically.

Accessing "From my mac" in PhotoKit
 
 
Q