[英]How to resolve “Missing Info.plist key … NSPhotoLibraryUsageDescription”
[英]NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll
感谢@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>
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>
家用套件:
<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>
您需要将这两个粘贴到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>
对于相机访问,请使用:
<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
截至 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>
为了保存或从相机胶卷检索图像。 此外,您需要向用户询问权限,否则将收到此错误,否则您的应用程序可能会崩溃。 为了避免这种情况,请将其添加到您的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".
"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>
如果您在Info.plist中添加了密钥-字符串对( 请参阅上面的Murat的答案 ),但仍然出现错误,请尝试检查您当前正在处理的目标是否具有密钥。
就我而言,我有两个目标(开发和开发)。 我在编辑器中添加了键,但是它仅适用于主要目标,并且我正在测试开发目标。 因此,我不得不打开XCode,单击项目> Info>在此处添加开发目标的密钥对。
使用NSCameraUsageDescription
,用户可以访问相机并从照片库中选择图像。 所以我不需要NSPhotoLibraryUsageDescription
,对吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.