Crash requesting permission for Photo Library in iOS 10

I have an example iOS 10 application requesting authorization in the Photo Library and crashing on a real device with the following error on crash:

PhotosAuthorizationCrashTest[2014:42551] [access] <private>

Repo can be found here

Here is the code requesting authorization (Swift 3.0):

private func requestAuthorizationIfNeeded() {
    DispatchQueue.main.async {
        let status = PHPhotoLibrary.authorizationStatus()
        if status == .authorized {
            return
        }

        PHPhotoLibrary.requestAuthorization({ (status) in
            if status == .authorized {
                return
            }

            NSLog("Could not get authorization to access photos")
        })
    }
}
+4
source share
1 answer

I found that the problem is that some usage description keys have become mandatory in iOS 10.

Although it NSPhotoLibraryUsageDescriptionexists with iOS 6, this was only a requirement in iOS 10, and the error message was not very useful.

Xcode (Xcode 8 beta 3 ) ( ):

[access] , . Info.plist NSPhotoLibraryUsageDescription , , .

NSPhotoLibraryUsageDescription Info.plist .

. Cocoa

, NSPhotoLibraryUsageDescription:

. , iOS, iOS 10.0 , , . Info.plist NSPhotoLibraryUsageDescription . , .

+8

Source: https://habr.com/ru/post/1649449/


All Articles