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

33,680

Solution 1

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

Solution 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>
Share:
33,680
Ahmad F
Author by

Ahmad F

I appreciate your kind comments/suggestions and edits to my posts. Feel free to use any code in my posts without attribution (that's what usually happens anyway 😅). I don't usually downvote, but when I do, I mention the reason. It would be nice if you check my stories ✍️ My "humble" todo list so far: ✅ Swift tag: Silver Badge. ✅ iOS tag: Silver Badge. ✅ 10k Reputation. ✅ Swift tag: Gold Badge. ✅ 15k Reputation. ✅ iOS tag: Gold Badge. ✅ IMPACT ~1m people reached (hopefully, being useful to good amount of people). ✅ 10 Gold Badges. 🔫 25k Reputation (getting all privileges). Oh boy it could go on forever! but I am satisfied with it so far... Highest 100 users reputation located at: 😀 Jordan 😐 Arabs Users I follow:

Updated on July 27, 2022

Comments

  • Ahmad F
    Ahmad F almost 2 years

    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?

  • Cutterpillow
    Cutterpillow over 6 years
    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.
  • Ahmad F
    Ahmad F over 6 years
    @Cutterpillow I think your second assumption it correct.
  • iWheelBuy
    iWheelBuy about 6 years
    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 bug
  • David Jarrin
    David Jarrin over 4 years
    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.
  • A. Amini
    A. Amini almost 4 years
    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? @AhmadF
  • Ahmad F
    Ahmad F almost 4 years
    @A.Amini you have to add it into the plist.