2016-09-15 94 views
99

最近,我开始收到此错误:NSPhotoLibraryUsageDescription键必须出现在Info.plist中使用相机胶卷

NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll.

我使用本机作出反应来构建我的应用程序(我不熟悉的iOS原生的发展)我不知道如何将此密钥添加到Info.plist

您可以发布示例吗?由于

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

enter image description here

+1

见http://stackoverflow.com/a/39476283/1226963为了什么要添加到Info.plist中的例子。此外,只要在'NSPhotoLibraryUsageDescription'上搜索一下就可以找到很多例子。 – rmaddy

回答

258

感谢@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> 
+12

我一直在使用字符串,“这个应用程序不需要访问照片库。” –

+0

我已经在info.plist文件中添加了键和字符串,然后我使用终端构建应用程序,所有这些更改已被删除。请指导它 –

+0

我加了这个,但它仍然崩溃了相同的错误。为什么发生这种情况? – fish40

3

摄像头的访问使用:

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

MY FAVORITE方式做到这一点

1.打开info.plist

enter image description here

2。单击此按钮可以添加一个新的关键

enter image description here

3.向下滚动找到隐私 - 图片库使用情况说明

enter image description here

4.选择它,然后在右侧添加您的说明

在Info.plist文件0

enter image description here

+0

我加了这个,但是它仍然崩溃,同样的错误。为什么发生这种情况? – fish40

+4

@ fish40也许你可以尝试点击project-target-info,并将它添加到那里,看看会发生什么? –

+0

@Brigt Future谢谢你的工作 – fish40

15

添加以下代码

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

enter image description here

+1

这正是我所需要的......用源代码的方式,我终于成功地上传了我的应用程序! TNX :) – BvdVen

+0

奇怪的是,这工作,但其他方法没有,也许这只是一个错误在Xcode 9测试版。非常感谢! – JohnV

+0

欢迎,很高兴这对你有帮助。 –

2

您需要这两个在您的info.plist贴,它是唯一的方式,它的工作对我来说ios11

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

感谢这段代码真的帮我:) –

+0

不客气。 @thakur –

0

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

"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> 
相关问题