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"
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>
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>
For camera access use:
<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
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".
"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>
来源:https://stackoverflow.com/questions/39519773/nsphotolibraryusagedescription-key-must-be-present-in-info-plist-to-use-camera-r