iOS 10 Photo Authorization (Simulator)

Using the sample app at https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson4.html#//apple_ref/doc/uid/TP40015214-CH6-SW1


iOS 9 simulator prompts for Photo authorization. Building the same app in iOS 10, making affordances for the updated API, crashes immediately upon tapping the imageView gesture recognizer (to present uiimagepicker).


I am never prompted for Photo Access authorizaiton. Further inspection shows that the authorization status is returning 'not determined'.

Accepted Reply

Running on device gave much better error information in the console.

This app has crashed because it attempted to access privacy-sensitive data without a usage description.  
The app's Info.plist must contain an NSPhLibraryUsageDescription key with a string value explaining to the user how the 
app uses this data.


All is well, now 🙂


From the docs:

Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s photo library,
must statically declare the intent to do so. Include the NSPhotoLibraryUsageDescription key in your app’s Info.plist
file and provide a purpose string for this key. If your app attempts to access the user’s photo library without a
corresponding purpose string, your app exits.

More details: https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

Replies

Running on device gave much better error information in the console.

This app has crashed because it attempted to access privacy-sensitive data without a usage description.  
The app's Info.plist must contain an NSPhLibraryUsageDescription key with a string value explaining to the user how the 
app uses this data.


All is well, now 🙂


From the docs:

Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s photo library,
must statically declare the intent to do so. Include the NSPhotoLibraryUsageDescription key in your app’s Info.plist
file and provide a purpose string for this key. If your app attempts to access the user’s photo library without a
corresponding purpose string, your app exits.

More details: https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

I ran into the same thing and wondered why the app terminated in the simulator with no indication as to why. Thank you for posting this!

thank you so much, helpful for newbie 🙂

I'm having a similar issue with this tutorial. The simulator will run, but when i click the image view, the app doesn't crash, but it also doesn't do anything. I'm expecting to be able to select a photo from the library, but nothing happens. I'm not even prompted for permissions. Anyone else having this issue?

Just add this key into your info.plist

NSPhotoLibraryUsageDescription

and also specify your own string in Value column

I have NSPhotoLibraryUsageDescription key with string, yet still crash in xCode 8.2.1. Deleted app and did fresh build, still crashes.

I'm having a similar problem. I even resorted tosetting all the privacy key and still see an error messages and the app doesn't even exit. I'm using Mac OSX 10.12.4, Xcode 8.2.1 and iOS Simulator 10.2.