Failure accessing the Photo library when app is 1st installed on iOS 15.2

Context:

  • Using Xcode 13.2 and building on iOS 15.2 devices
  • When installing the app for the 1st time on a device or simulator.

Issue:

  • When building and installing an app that requests access to the user’s Photo library, Xcode logs a  [GatekeeperXPC] Failed to open photo library error even before the app requests photo library access.

Xcode Log example:

2021-12-16 18:33:57.848222+0100 App[20166:691616] [GatekeeperXPC] Failed to open photo library Error Domain=com.apple.photos.error Code=41011 "Unauthorized access: client does not have valid TCC authorization" UserInfo={NSLocalizedDescription=Unauthorized access: client does not have valid TCC authorization}

2021-12-16 18:33:57.848560+0100 App[20166:691616] [GatekeeperXPC] Got a bind failure for URL file:///Users/manuel/Library/Developer/CoreSimulator/Devices/F6302FEB-0448-4BAC-89A9-E34E8801B894/data/Media/, resetting bind state: <PLResult:0x600000cc5d40> failure: Error Domain=com.apple.photos.error Code=41011 "Unauthorized access: client does not have valid TCC authorization" UserInfo={NSLocalizedDescription=Unauthorized access: client does not have valid TCC authorization} (previous result: (null))

2021-12-16 18:33:57.849131+0100 App[20166:691616] [GatekeeperXPC] XPC connection error to assetsd getLibraryServiceWithReply: : Error Domain=com.apple.photos.error Code=41011 "Unauthorized access: client does not have valid TCC authorization" UserInfo={NSLocalizedDescription=Unauthorized access: client does not have valid TCC authorization}

2021-12-16 18:33:57.849507+0100 App[20166:691616] [Backend] Swallowing proxy invocation: <NSInvocation: 0x6000019ede80> getLibraryServiceWithReply:

CoreData: XPC:  Unable to create NSXPCConnection

CoreData: fault: Something has gone badly awry initializing the XPC connection pool: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil

2021-12-16 18:33:57.855954+0100 App[20166:691616] CoreData: XPC: sendMessage: failed #0

  • After photo library access is granted, the Photos framework methods don't return any assets/albums etc. Nothing.

  • Building for iOS 15.0 devices and Sims works fine.

Anyone else seing this?

Answered by zavenmadoyan in 698863022

Before iOS 15.2 version we could register PHPhotoLibrary.shared().register(self) without authorization, in iOS 15.2 it is not possible, you will get an error. You have to request authorization(requestAuthorization(_:)) for register PHPhotoLibrary.shared().register(self).

Yes, also seeing this under same context. Was looking forward to iOS 15.2 since iOS 15.0 simulator had a bug with typeText(:) taking forever, but seems like Photo permissions is broken in this new version.

We get the same after call PHPhotoLibrary.shared().register(self) ((

This is still happening on Xcode 13.2.1

Accepted Answer

Before iOS 15.2 version we could register PHPhotoLibrary.shared().register(self) without authorization, in iOS 15.2 it is not possible, you will get an error. You have to request authorization(requestAuthorization(_:)) for register PHPhotoLibrary.shared().register(self).

Failure accessing the Photo library when app is 1st installed on iOS 15.2
 
 
Q