使用iOS 10.0
最后一个测试版。我曾尝试使用相机扫描我的应用程序中的条形码,但它因运行时错误而崩溃。
此应用程序已崩溃,因为它试图在没有使用说明的情况下访问隐私敏感数据。应用的 Info.plist 必须包含一个 NSCameraUsageDescription 键和一个字符串值,向用户解释应用如何使用这些数据。
把这个key放到plist里面,还是crash了?
使用iOS 10.0
最后一个测试版。我曾尝试使用相机扫描我的应用程序中的条形码,但它因运行时错误而崩溃。
此应用程序已崩溃,因为它试图在没有使用说明的情况下访问隐私敏感数据。应用的 Info.plist 必须包含一个 NSCameraUsageDescription 键和一个字符串值,向用户解释应用如何使用这些数据。
把这个key放到plist里面,还是crash了?
在 iOS 10 之后,您必须在 Info.plist 中定义并提供应用程序访问的所有系统隐私敏感数据的使用说明,如下所示:
日历
Key : Privacy - Calendars Usage Description
Value : $(PRODUCT_NAME) calendar events
提醒 :
Key : Privacy - Reminders Usage Description
Value : $(PRODUCT_NAME) reminder use
接触 :
Key : Privacy - Contacts Usage Description
Value : $(PRODUCT_NAME) contact use
照片 :
Key : Privacy - Photo Library Usage Description
Value : $(PRODUCT_NAME) photo use
蓝牙分享:
Key : Privacy - Bluetooth Peripheral Usage Description
Value : $(PRODUCT_NAME) Bluetooth Peripheral use
麦克风 :
Key : Privacy - Microphone Usage Description
Value : $(PRODUCT_NAME) microphone use
相机 :
Key : Privacy - Camera Usage Description
Value : $(PRODUCT_NAME) camera use
地点 :
Key : Privacy - Location Always Usage Description
Value : $(PRODUCT_NAME) location use
Key : Privacy - Location When In Use Usage Description
Value : $(PRODUCT_NAME) location use
希思:
Key : Privacy - Health Share Usage Description
Value : $(PRODUCT_NAME) heath share use
Key : Privacy - Health Update Usage Description
Value : $(PRODUCT_NAME) heath update use
家庭套件:
Key : Privacy - HomeKit Usage Description
Value : $(PRODUCT_NAME) home kit use
媒体库:
Key : Privacy - Media Library Usage Description
Value : $(PRODUCT_NAME) media library use
运动 :
Key : Privacy - Motion Usage Description
Value : $(PRODUCT_NAME) motion use
语音识别 :
Key : Privacy - Speech Recognition Usage Description
Value : $(PRODUCT_NAME) speech use
SiriKit:
Key : Privacy - Siri Usage Description
Value : $(PRODUCT_NAME) siri use
电视提供商:
Key : Privacy - TV Provider Usage Description
Value : $(PRODUCT_NAME) tvProvider use
您可以在此链接中获取详细信息。
您必须在 info.plist 中添加以下键。
NSCameraUsageDescription
或者
Privacy - Camera usage description
并添加使用说明。
此链接中提供了详细的屏幕截图
或者打开 Info.plist 作为源代码并添加:
<key>NSCameraUsageDescription</key>
<string>Camera usage description</string>
使用这些原始值并复制到 info.plist
<key>NSCalendarsUsageDescription</key>
<string>$(PRODUCT_NAME) calendar events</string>
<key>NSRemindersUsageDescription</key>
<string>$(PRODUCT_NAME) reminder use</string>
<key>NSCameraUsageDescription</key>
<string>This app requires to access your photo library to show image on profile and send via chat</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires to access your microphone to record video with your voice send via chat</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires to access your photo library to show image on profile and send via chat</string>
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) contact use</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) location use</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) location use</string>
对于那些即使您在 Info.plist 中添加了正确的键仍然遇到错误的人:
确保将密钥添加到正确的 Info.plist 中。较新版本的 xCode,显然有 3 Info.plist。
一个位于您的应用程序名称的文件夹下,它为我解决了问题。
第二个在 YourappnameTests 下,第三个在 YourappnameUITests 下。
希望能帮助到你。
如果您使用的是 Ionic,则可以通过添加内部平台 ios 标记直接从config.xml解决它:
<platform name="ios">
.
.
.
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
<string>photo library usage description</string>
</config-file>
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
<string>camera usage description</string>
</config-file>
.
.
.
</platform>
我也要感谢@BHUPI 的回答。
我在尝试使用相机时遇到的另一个例子是,_CRASHING_DUE_TO_PRIVACY
即使添加了“相机使用说明”,它仍然忙于崩溃。在未能从调用堆栈中获得任何有形的东西后,切换到“组织者”并查看设备上的崩溃报告。我发现它实际上是在抱怨由于缺少“麦克风使用说明”而导致的隐私。我添加了这一点,并摆脱了这种神秘的故障。
我检查了 plist 发现它不起作用,只有在“项目”信息中,您需要添加“隐私 - 相机 ....”,然后它应该可以工作。希望能帮到你。
为此,您可以向应用的 Info.plist 中添加使用密钥以及目的字符串。NSCameraUsageDescription 指定你的应用访问设备摄像头的原因
我遇到了同样的问题,找不到解决方案。Mark90 是对的,有很多 info.plist 文件,你应该编辑正确的。转到项目,在目标下选择项目(不是测试),在选项卡栏中选择信息并在“自定义 iOS 目标属性”下添加权限。