NSPhotoLibrary使用说明键必须在Info.plist中才能使用相机胶卷

最近我开始得到这个错误:

NSPhotoLibrary使用说明键必须在Info.plist中才能使用相机胶卷。

我正在使用React Native构build我的应用程序(我不熟悉ios本机开发),我不知道如何将此密钥添加到Info.plist

你能举一个例子吗? 谢谢

我使用npm包"react-native-camera-roll-picker": "^1.1.7"

在这里输入图像说明

谢谢@rmaddy,我在Info.plist中的其他关键字对之后加了这个,并解决了这个问题:

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

编辑:

我也结束了在我的应用程序的不同组件上类似的问题。 到目前为止,已经添加了所有这些密钥(在更新到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> 

检查这个developer.apple.com链接的属性列表中的关键引用的完整列表

完整列表:

苹果音乐:

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

蓝牙:

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

日历:

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

相机:

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

联系方式:

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

健康分享:

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

健康更新:

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

主页套件:

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

位置:

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

位置(始终):

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

位置(使用时):

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

麦克风:

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

运动(加速度计):

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

照片库:

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

提醒:

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

语音识别:

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

我最喜欢的方式来做

1.打开info.plist

在这里输入图像说明

2.点击此button添加一个新的密钥

在这里输入图像说明

3.向下滚动以查找 隐私 – 照片库使用说明

在这里输入图像说明

4.select它,然后在右侧添加您的描述

在这里输入图像说明

在info.plist文件中添加以下代码

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

在这里输入图像说明

用于相机访问使用:

 <key>NSCameraUsageDescription</key> <string>Camera Access Warning</string>