最近我开始收到此错误:
NSPhotoLibraryUsageDescription键必须存在于Info.plist中 使用相机胶卷。
我正在使用React Native来构建我的应用程序(我不熟悉ios本机开发)并且我不知道如何将此密钥添加到Info.plist
你能发一个例子吗?感谢
我正在使用npm包"react-native-camera-roll-picker": "^1.1.7"
答案 0 :(得分:337)
谢谢@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链接,了解完整列表的属性列表键引用。
完整列表:
Apple Music:
<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>
FaceID:
<key>NSFaceIDUsageDescription</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>
Home Kit:
<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>
NFC(近场通信):
<key>NFCReaderUsageDescription</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>NSPhotoLibraryAddUsageDescription</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 :(得分:54)
答案 2 :(得分:17)
在info.plist文件中添加以下代码
<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>
答案 3 :(得分:7)
你需要在info.plist中粘贴这两个,这是iOS 11中唯一适用的方式。
<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>
答案 4 :(得分:4)
使用相机:
<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
答案 5 :(得分:0)
"Privacy - Photo Library Additions Usage Description" for iOS 11 and later
"Privacy - Photo Library Usage Description" for iOS 6.0 and later
打开plist文件和此代码
<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>
答案 6 :(得分:0)
为了保存或从相机胶卷检索图像。此外,您需要向用户询问权限,否则将收到此错误,否则您的应用程序可能会崩溃。要从中保存自己,请将其添加到您的info.plist
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires read and write permission from the user.</string>
对于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".
答案 7 :(得分:0)
如果您在Info.plist(see Murat's answer above)中添加了密钥-字符串对,但仍然出现错误,请尝试检查您当前正在工作的目标是否具有密钥。
就我而言,我有2个目标(开发和开发)。我在编辑器中添加了键,但是它仅适用于主要目标,并且我正在测试开发目标。因此,我不得不打开XCode,单击项目> Info>在此处添加开发目标的密钥对。
答案 8 :(得分:0)
几天前,我的IONIC 4项目也遇到了同样的问题。当我上传IPA时,我从App Store Connect收到此警告。
我通过以下步骤解决了“ info.plist中缺少目的字符串”的问题。希望它也对您有用。
Privacy - Photo Library Usage Description
的键。如果它不存在,请添加一个新值,它的值如下图所示。谢谢。
答案 9 :(得分:0)
使用 NSCameraUsageDescription
时,用户可以访问相机并从照片库中选择图像。所以我不需要NSPhotoLibraryUsageDescription
,对吗?
答案 10 :(得分:0)
截至 2021 年 8 月, 我们不仅要添加这个:
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to photo library so that photos can be selected</string>
但还需要将此添加到iOS文件夹中的info.plist文件中才能正常工作
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires access to the photo library.</string>