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

12

213

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

Android answered 15/9, 2016 at 20:25 Comment(1)
See https://mcmap.net/q/128578/-ios-10-gm-release-error-when-submitting-apps-quot-app-attempts-to-access-privacy-sensitive-data-without-a-usage-description-quot-due-to-googlesignin-admob for an example of what to add to Info.plist. Also, just do a search on NSPhotoLibraryUsageDescription and you'll find plenty of examples.Datestamp
A
550

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

<key>NSPhotoLibraryUsageDescription</key>
<string>Photo Library Access Warning</string>

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):

<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app does not require access to the microphone.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>

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

Full List:

Apple Music:

<key>NSAppleMusicUsageDescription</key>
<string>My description about why I need this capability</string>

Bluetooth:

<key>NSBluetoothPeripheralUsageDescription</key>  
<string>My description about why I need this capability</string>

Calendar:

<key>NSCalendarsUsageDescription</key>
<string>My description about why I need this capability</string>

Camera:

<key>NSCameraUsageDescription</key>
<string>My description about why I need this capability</string>

Contacts:

<key>NSContactsUsageDescription</key>
<string>My description about why I need this capability</string>

FaceID:

<key>NSFaceIDUsageDescription</key>
<string>My description about why I need this capability</string>

Health Share:

<key>NSHealthShareUsageDescription</key>
<string>My description about why I need this capability</string>

Health Update:

<key>NSHealthUpdateUsageDescription</key>
<string>My description about why I need this capability</string>

Home Kit:

<key>NSHomeKitUsageDescription</key>
<string>My description about why I need this capability</string>

Location:

<key>NSLocationUsageDescription</key>
<string>My description about why I need this capability</string>

Location (Always):

<key>NSLocationAlwaysUsageDescription</key>
<string>My description about why I need this capability</string>

Location (When in use):

<key>NSLocationWhenInUseUsageDescription</key>
<string>My description about why I need this capability</string>

Microphone:

<key>NSMicrophoneUsageDescription</key>
<string>My description about why I need this capability</string>

Motion (Accelerometer):

<key>NSMotionUsageDescription</key>
<string>My description about why I need this capability</string>

NFC (Near-field communication):

<key>NFCReaderUsageDescription</key>
<string>My description about why I need this capability</string>

Photo Library:

<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>

Photo Library (Write-only access):

<key>NSPhotoLibraryAddUsageDescription</key>
<string>My description about why I need this capability</string>

Reminders:

<key>NSRemindersUsageDescription</key>
<string>My description about why I need this capability</string>

Siri:

<key>NSSiriUsageDescription</key>
<string>My description about why I need this capability</string>

Speech Recognition:

<key>NSSpeechRecognitionUsageDescription</key>
<string>My description about why I need this capability</string>
Android answered 15/9, 2016 at 20:37 Comment(4)
I have been using the string, "This app does not require access to the photo library."Ahmadahmar
I have added key and string in info.plist file then i build app using terminal and all these changes has been removed. please guide on itKalliekallista
I added this but it still crashing with same error. Why this is happening?Moral
where to find info.plist file in ionic ? I am not able to get that.Mcmanus
M
85

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

Management answered 18/2, 2017 at 10:6 Comment(7)
I added this but it still crashing with same error. Why this is happening?Moral
@Moral maybe you can try clicking project-target-info, and add it there and see what happens?Management
your key description made my day XDPopover
Usage description tickled me. Fixed my issue too so happy bonus!Seafarer
where to find info.plist file ? I am not able to get that.Mcmanus
@Mcmanus if you can't find it, you might've deleted it. You can create a new one by File -> New -> FileManagement
@Mcmanus check here where to find info.plistDamage
V
21

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

<key>NSPhotoLibraryUsageDescription</key> 
<string>We need access to photo library so that photos can be selected</string>

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

<key>NSPhotoLibraryAddUsageDescription</key>    
<string>This app requires access to the photo library.</string>
Volplane answered 11/8, 2021 at 15:38 Comment(0)
K
18

Add following code in info.plist file

<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>

enter image description here

Kalliekallista answered 6/3, 2017 at 12:43 Comment(3)
This was exactly what I needed... with the source way I finally succeeded in uploading my app! TNX :)Petulance
It's strange that this worked, but the other approaches didn't, maybe it's just a bug on xcode 9 beta. Many thanks for this!!!Philemol
Welcome, Happy it's help to you.Kalliekallista
G
16

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

    <key>NSPhotoLibraryUsageDescription</key>
    <string>This app requires access to the photo library.</string>

    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>This app requires access to the photo library.</string>
Guipure answered 5/1, 2018 at 23:2 Comment(1)
The latter is only required if you are requesting permission to add to the photo library. DocsThirlage
O
5

For camera access use:

<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
Olfe answered 28/9, 2016 at 9:2 Comment(0)
M
3

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.

Montane answered 7/7, 2020 at 13:32 Comment(0)
E
2

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

Entoderm answered 7/5, 2021 at 11:7 Comment(0)
P
1

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

<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires read and write permission from the user.</string>

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".
Pilsner answered 18/5, 2019 at 7:16 Comment(0)
L
1

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.

Lilybel answered 28/11, 2019 at 15:45 Comment(1)
This was my case too. Thank you!Transcontinental
S
0

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

<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires access to the photo library.</string>
Serious answered 8/2, 2018 at 6:30 Comment(0)
M
0

I got this same error while uploading my flutter app to app store connect. STEPS I EMPLOYED TO FIX IT:

  1. Opened the ios folder of my flutter project in XCode
  2. Inside the runner folder, I clicked on info.split file
  3. clicked + button in front of "information property list"
  4. I scroll down until I find "privacy - Photo Library Usage Description". I clicked on that.
  5. Then input a description message of why you seek the photo permission in the string section. In my case, the string I supplied was -> "This app need permission to access camera and photo library".
Manage answered 31/5, 2023 at 12:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.