NSPhotoLibraryUsageDescription 密钥必须存在于 Info.plist 中才能使用相机胶卷
NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll
最近我开始遇到这个错误:
NSPhotoLibraryUsageDescription key must be present in Info.plist to
use camera roll.
我正在使用 React Native 构建我的应用程序(我不熟悉 ios 原生开发)并且我不知道如何将此密钥添加到 Info.plist
你能post举个例子吗?谢谢
我正在使用 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 link 以获得 完整列表 的 属性 列表关键引用。
完整列表:
苹果音乐:
<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>
面容 ID:
<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>
相机访问使用:
<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
我最喜欢的方式
1.打开info.plist
2。单击此按钮添加新密钥
3。向下滚动找到 隐私 - 照片库使用说明
4。 Select它,然后在右边添加你的描述
在info.plist文件中添加以下代码
<key>NSPhotoLibraryUsageDescription</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>
"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
<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".
如果您在 Info.plist ( ) 中添加了密钥-字符串对,但仍然出现错误,请尝试检查您当前正在处理的目标是否有密钥。
在我的例子中,我有 2 个目标(开发和开发)。我在编辑器中添加了键,但它只适用于主要目标,我正在测试开发目标。所以我不得不打开 XCode,点击项目 > 信息 > 在那里添加开发目标的密钥对。
几天前我的 IONIC 4 项目遇到了同样的问题。当我上传我的 IPA 时,我从 App Store Connect 收到了这个警告。
我通过以下步骤解决了“info.plist 中缺少目的字符串”的问题。希望它也对你有用。
- 转到您的“info.plist”文件。
- 找到这个名为
Privacy - Photo Library Usage Description
的键。如果那里不存在,请添加一个新的和它的值,如下图所示。
谢谢。
使用 NSCameraUsageDescription
时,用户可以访问相机和照片库中的 select 图像。所以我不需要 NSPhotoLibraryUsageDescription
,对吗?
截至 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>
最近我开始遇到这个错误:
NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll.
我正在使用 React Native 构建我的应用程序(我不熟悉 ios 原生开发)并且我不知道如何将此密钥添加到 Info.plist
你能post举个例子吗?谢谢
我正在使用 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 link 以获得 完整列表 的 属性 列表关键引用。
完整列表:
苹果音乐:
<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>
面容 ID:
<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>
相机访问使用:
<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
我最喜欢的方式
1.打开info.plist
2。单击此按钮添加新密钥
3。向下滚动找到 隐私 - 照片库使用说明
4。 Select它,然后在右边添加你的描述
在info.plist文件中添加以下代码
<key>NSPhotoLibraryUsageDescription</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>
"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
<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".
如果您在 Info.plist (
在我的例子中,我有 2 个目标(开发和开发)。我在编辑器中添加了键,但它只适用于主要目标,我正在测试开发目标。所以我不得不打开 XCode,点击项目 > 信息 > 在那里添加开发目标的密钥对。
几天前我的 IONIC 4 项目遇到了同样的问题。当我上传我的 IPA 时,我从 App Store Connect 收到了这个警告。
我通过以下步骤解决了“info.plist 中缺少目的字符串”的问题。希望它也对你有用。
- 转到您的“info.plist”文件。
- 找到这个名为
Privacy - Photo Library Usage Description
的键。如果那里不存在,请添加一个新的和它的值,如下图所示。
谢谢。
使用 NSCameraUsageDescription
时,用户可以访问相机和照片库中的 select 图像。所以我不需要 NSPhotoLibraryUsageDescription
,对吗?
截至 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>