Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the crash of "The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription"?

I faced the following error (iOS 11):

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

Note that although the application info.plist does contains NSPhotoLibraryUsageDescription it still crashes, why?

like image 562
Ahmad F Avatar asked Oct 11 '17 06:10

Ahmad F


2 Answers

Note that although the application info.plist does contains NSPhotoLibraryUsageDescription it still crashes, why?

I think there is a misunderstanding when comparing NSPhotoLibraryUsageDescription and NSPhotoLibraryAddUsageDescription, as documented in Information Property List Key Reference:

NSPhotoLibraryUsageDescription:

This key lets you describe the reason your app accesses the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

It is related to letting the app to be able to access (get) the device photos library.

NSPhotoLibraryAddUsageDescription:

This key lets you describe the reason your app seeks write-only access to the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

It is related to letting the app to be able to write (add) photos into the device photos library.


Obviously, to solve this crash you have to add the NSPhotoLibraryAddUsageDescription into the application's plist file:

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Our application needs permission to write photos...</string>

As property list view:

enter image description here

like image 171
Ahmad F Avatar answered Nov 12 '22 21:11

Ahmad F


There is a typo in the above answer. The correct plist entry should be as follows

<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) needs permission to access photos on your device</string>
like image 25
Arunabh Das Avatar answered Nov 12 '22 21:11

Arunabh Das