Recently I started to get this error:

NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll.

I am using React Native to build my app (I am not familiar with ios native development) and I don't know how to add this key to Info.plist

Can you post an example? Thanks

I am using npm package "react-native-camera-roll-picker": "^1.1.7"

enter image description here

Murat Ozgul

Ответов: 11

Ответы (11)

Thanks @rmaddy, I added this just after other key-string pairs in Info.plist and fixed the problem:

NSPhotoLibraryUsageDescription
Photo Library Access Warning

Edit:

I also ended up having similar problems on different components of my app. Ended up adding all these keys so far (after updating to Xcode8/iOS10):

NSPhotoLibraryUsageDescription
This app requires access to the photo library.
NSMicrophoneUsageDescription
This app does not require access to the microphone.
NSCameraUsageDescription
This app requires access to the camera.

Checkout this developer.apple.com link for full list of property list key references.

Full List:

Apple Music:

NSAppleMusicUsageDescription
My description about why I need this capability

Bluetooth:

NSBluetoothPeripheralUsageDescription  
My description about why I need this capability

Calendar:

NSCalendarsUsageDescription
My description about why I need this capability

Camera:

NSCameraUsageDescription
My description about why I need this capability

Contacts:

NSContactsUsageDescription
My description about why I need this capability

FaceID:

NSFaceIDUsageDescription
My description about why I need this capability

Health Share:

NSHealthShareUsageDescription
My description about why I need this capability

Health Update:

NSHealthUpdateUsageDescription
My description about why I need this capability

Home Kit:

NSHomeKitUsageDescription
My description about why I need this capability

Location:

NSLocationUsageDescription
My description about why I need this capability

Location (Always):

NSLocationAlwaysUsageDescription
My description about why I need this capability

Location (When in use):

NSLocationWhenInUseUsageDescription
My description about why I need this capability

Microphone:

NSMicrophoneUsageDescription
My description about why I need this capability

Motion (Accelerometer):

NSMotionUsageDescription
My description about why I need this capability

NFC (Near-field communication):

NFCReaderUsageDescription
My description about why I need this capability

Photo Library:

NSPhotoLibraryUsageDescription
My description about why I need this capability

Photo Library (Write-only access):

NSPhotoLibraryAddUsageDescription
My description about why I need this capability

Reminders:

NSRemindersUsageDescription
My description about why I need this capability

Siri:

NSSiriUsageDescription
My description about why I need this capability

Speech Recognition:

NSSpeechRecognitionUsageDescription
My description about why I need this capability

For camera access use:

NSCameraUsageDescription
Camera Access Warning

Add following code in info.plist file

NSPhotoLibraryUsageDescription
My description about why I need this capability

enter image description here

i faced the same issue few days earlier for my IONIC 4 Project. when i uploaded my IPA, i got this warnings from App Store Connect.

enter image description here

I fixed the "Missing Purpose String in info.plist" issue, by the following steps. hope it will also work for you.

  1. Goto your "info.plist" file.

enter image description here

  1. Find this key, called Privacy - Photo Library Usage Description. if it's not present there, add a new one and it's value, like below image.

enter image description here

Thanks.

In order to save or retrieve an image from the camera roll. Additionally, you need to ask the user for the permission otherwise you'll get this error or your app may get crashed. To save yourself from this add this into your info.plist

NSPhotoLibraryAddUsageDescription
This app requires read and write permission from the user.

In the case of Xamarin.iOS

 if you're adding it from the generic editor then "Privacy - Photo Library Additions Usage Description" will be the given option you will find out instead of "NSPhotoLibraryAddUsageDescription".

As of now August 2021, not only we have to add this :

NSPhotoLibraryUsageDescription 
We need access to photo library so that photos can be selected

but also need to add this to info.plist file inside iOS folder in order to work properly

NSPhotoLibraryAddUsageDescription    
This app requires access to the photo library.

When using NSCameraUsageDescription the user can access the camera AND select images from the photo library. So I don’t need NSPhotoLibraryUsageDescription, correct?

You need to paste these two in your info.plist, The only way that worked in iOS 11 for me.

    NSPhotoLibraryUsageDescription
    This app requires access to the photo library.

    NSPhotoLibraryAddUsageDescription
    This app requires access to the photo library.

If you added the key-string pairs in Info.plist (see Murat's answer above ) and still getting the error, try to check if the target you're currently working on has the keys.

In my case I had 2 targets (dev and development). I added the keys in the editor, but it only works for the main target and I was testing on development target. So I had to open XCode, click on the project > Info > Add the key-pair for the development target there.

MY FAVORITE WAY TO DO IT

1. Open info.plist

enter image description here

2. Click this button to add a new key

enter image description here

3. Scroll down to find Privacy - Photo Library Usage Description

enter image description here

4. Select it, then add your description on the right

enter image description here

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

"Privacy - Photo Library Additions Usage Description" for iOS 11 and later

"Privacy - Photo Library Usage Description" for iOS 6.0 and later

Open plist file and this code

NSPhotoLibraryUsageDescription
This app requires access to the photo library.

NSPhotoLibraryAddUsageDescription
This app requires access to the photo library.

2022 WebDevInsider