PhotoKit: Can't access user's albums?

Using Xcode 13 beta 4, I seem to have lost the ability to access user-created photo albums with PhotoKit (via PHAssetCollection.fetchAssetCollections). When I request albums of the type .smartAlbum, I get all the Smart Albums. However when I request .album, I get 0 results. Has anyone else run into this?

Here's some example code:

import SwiftUI
import Photos

struct ContentView: View {
	@State var status: PHAuthorizationStatus = PHPhotoLibrary
		.authorizationStatus(for: .readWrite)

	private static var collectionOptions: PHFetchOptions {
		let reverseChron = PHFetchOptions()
		reverseChron.sortDescriptors = [NSSortDescriptor(keyPath: \PHAssetCollection.endDate, ascending: false)]
		return reverseChron
	}

    var body: some View {
		VStack {
			Text("Welcome!")
				.padding()
			if status == .authorized {
				Button("Load photos") {
					let userAlbums = PHAssetCollection.fetchAssetCollections(
						with: .album,
						subtype: .any,
						options: ContentView.collectionOptions
					)
					print("List of albums:")
					for i in 0..<userAlbums.count {
						let album = userAlbums[i]
						print(album.localizedTitle ?? "[No title]")
					}
				}
			}
		}.onAppear() {
			PHPhotoLibrary.requestAuthorization(for: .readWrite) { aStatus in
					  status = aStatus
				  }
			  }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Edit: filed as FB9477907

Answered by Engineer in 684515022

Thanks for filing the feedback! Are you still seeing this issue in the latest betas (Developer Seed 5)? A fix was included in those versions to correct this bug where apps that have .readWrite access to the photo library were not able to fetch user albums.

Seeing the same thing. Thank you for posting the code example.

Accepted Answer

Thanks for filing the feedback! Are you still seeing this issue in the latest betas (Developer Seed 5)? A fix was included in those versions to correct this bug where apps that have .readWrite access to the photo library were not able to fetch user albums.

I have a similar issue in Xcode 14.2. I see the message Failed to log access with error: access=<PATCCAccess 0x281ab0a00> accessor:<<PAApplication 0x281ac93b0 identifierType:auditToken identifier:{pid:12627, version:307689}>> ... but I seem to get access to what I'm requesting anyway.

PhotoKit: Can't access user's albums?
 
 
Q