NSCameraUsageDescription不起作用

时间:2017-03-14 22:29:09

标签: ios xcode info-plist

我正在尝试打开用户的相机,但每当我尝试打开相机时,我都会收到此错误,“应用程序已崩溃,因为它试图访问隐私敏感数据而没有使用说明。该应用程序的Info.plist必须包含一个NSCameraUsageDescription键,其中包含一个字符串值,向用户解释应用程序如何使用此数据。“我已经在info.plist文件中添加了隐私 - 相机使用说明以及“我需要使用您的相机”等值,但我仍然收到此错误。 这是我的info.plist

的源代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Needed to receive your current location.</string>
    <key>NSCameraUsageDescription</key>
    <string>Need to use camera for AR</string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

***我找到了解决方案。我必须进入“信息”并在自定义IOS目标属性中添加隐私密钥

1 个答案:

答案 0 :(得分:0)

很遗憾,在iOS 10之后,您必须定义对所有硬件的访问权限。最有可能的是,您将缺少“隐私 - 麦克风使用说明”。切换到“管理器”并查看设备上的崩溃报告,并添加其中列出的所有隐私错误。