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

3

40

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?

Citronellal answered 11/10, 2017 at 6:36 Comment(4)
why are you are asking question then if you know the answer ?Acidimetry
@VarunNaharia because I think it might be useful for anyone facing this crash. meta.#314665 it is legal :)Citronellal
There are already same question there you can answer there #46567472 #46344659Acidimetry
@VarunNaharia If I'm not mistaking, these options (as mentioned inhttps://mcmap.net/q/408086/-detect-add-photos-only-permission question) are unavailable for now... or at least I couldn't find them :)Citronellal
C
91

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

Citronellal answered 11/10, 2017 at 6:36 Comment(6)
Apple’s documentation for NSPhotoLibraryUsageDescription specifically states that it is for both read & write access: "Although this keys governs read and write access to the user’s photo library, it’s best to use NSPhotoLibraryAddUsageDescription if your app needs only to add assets to the library and does not need to read any assets.” I don’t know if this is just a bug in the Documentation or if Apple purposefully changed the behavior for NSPhotoLibraryUsageDescription to be read-only.Kauslick
@Kauslick I think your second assumption it correct.Citronellal
If you open iOS settings and navigation to your app you will see read and write with NSPhotoLibraryUsageDescription. That is why it looks like a bugGynandromorph
If you want to add photos to the library you need to use the "Privacy - Photo Library Additions Usage Description" key. I used both that key and the "Privacy - Photo Library Usage Description" keys and things worked properly.Emergence
Hi, still the same issue after a few years. My question is, how I can ask for permission for "NSPhotoLibraryAddUsageDescription"? Or I just need to add Key, String to my plist file? @AhmadFBrisance
@A.Amini you have to add it into the plist.Citronellal
M
2

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>
Mazurek answered 10/1, 2019 at 16:23 Comment(0)
M
0

You can add NSPhotoLibraryUsageDescription like this in info.plist. Hope this will fix your crash.

Mulford answered 26/5 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.