Info.plist中必须存在NSPhotoLibraryUsageDescription键才能使用相机胶卷

Mur*_*gul 143 info.plist ios react-native

最近我开始收到此错误:

Info.plist中必须存在NSPhotoLibraryUsageDescription键才能使用相机胶卷.

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

你能发一个例子吗?谢谢

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

在此输入图像描述

Mur*_*gul 358

谢谢@rmaddy,我在Info.plist中的其他键串对之后添加了这个并修复了问题:

<key>NSPhotoLibraryUsageDescription</key>
<string>Photo Library Access Warning</string>
Run Code Online (Sandbox Code Playgroud)

编辑:

我最终在我的应用程序的不同组件上遇到了类似的问题.到目前为止结束添加所有这些键(在更新到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>
Run Code Online (Sandbox Code Playgroud)

查看此developer.apple.com链接以获取属性列表键引用的完整列表.

完整清单:

Apple音乐:

<key>NSAppleMusicUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

蓝牙:

<key>NSBluetoothPeripheralUsageDescription</key>  
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

日历:

<key>NSCalendarsUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

相机:

<key>NSCameraUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

联系方式:

<key>NSContactsUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

FaceID:

<key>NSFaceIDUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

健康分享:

<key>NSHealthShareUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

健康更新:

<key>NSHealthUpdateUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

家庭套件:

<key>NSHomeKitUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

地点:

<key>NSLocationUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

位置(始终):

<key>NSLocationAlwaysUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

位置(使用时):

<key>NSLocationWhenInUseUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

麦克风:

<key>NSMicrophoneUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

运动(加速度计):

<key>NSMotionUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

NFC(近场通信):

<key>NFCReaderUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

图库:

<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

照片库(只读访问):

<key>NSPhotoLibraryAddUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

提醒:

<key>NSRemindersUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

Siri的:

<key>NSSiriUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

语音识别:

<key>NSSpeechRecognitionUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

  • 我一直在使用字符串,"此应用程序不需要访问照片库." (15认同)

Bri*_*ure 60

我最喜欢做的事情

1.打开 info.plist

在此输入图像描述

2.单击此按钮添加新密钥

在此输入图像描述

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

在此输入图像描述

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

在此输入图像描述

  • 你的关键描述使我的一天XD (11认同)
  • @ fish40也许你可以尝试点击project-target-info,然后在那里添加它,看看会发生什么? (5认同)
  • 使用说明让我感到痒痒。修复了我的问题太开心了! (2认同)

小智 21

截至 2021 年 8 月,我们不仅需要添加以下内容:

<key>NSPhotoLibraryUsageDescription</key> 
<string>We need access to photo library so that photos can be selected</string>
Run Code Online (Sandbox Code Playgroud)

但还需要将其添加到 iOS 文件夹内的 info.plist 文件中才能正常工作

<key>NSPhotoLibraryAddUsageDescription</key>    
<string>This app requires access to the photo library.</string>
Run Code Online (Sandbox Code Playgroud)


小智 17

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

<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  • 这正是我所需要的......通过源方式我终于成功上传了我的应用程序!TNX :) (2认同)

Rez*_*.Ab 8

你需要在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>
Run Code Online (Sandbox Code Playgroud)


Ori*_*Ori 5

对于相机访问使用:

<key>NSCameraUsageDescription</key>
<string>Camera Access Warning</string>
Run Code Online (Sandbox Code Playgroud)