NSCameraUsageDescription在启动代理OS Mojave上崩溃

时间:2019-05-02 17:40:32

标签: swift avfoundation macos-mojave

我有一个启动代理,要求访问摄像头。当我从Xcode运行应用程序时,会出现摄像头访问弹出窗口。但是,当我导出应用程序并从“应用程序”启动应用程序时,它不会显示弹出窗口,并崩溃并显示以下消息。

  

此应用程序已崩溃,因为它尝试访问没有使用说明的隐私敏感数据。该应用程序的Info.plist必须包含一个NSCameraUsageDescription键,该键具有一个字符串值,向用户解释该应用程序如何使用此数据

注意:我已在启动代理应用的info.plist中添加了NSCameraUsageDescription

在我的viewDidLoad()方法中,我正在检查相机权限。

if #available(OSX 10.14, *) {

        switch AVCaptureDevice.authorizationStatus(for: .audio) {
        case .authorized: // The user has previously granted access to the camera.
            NSLog("Audio Permission granted")

        case .notDetermined: // The user has not yet been asked for camera access.
            AVCaptureDevice.requestAccess(for: .audio) { granted in
                if granted {
                    NSLog("Audio Permission granted")

                } else {
                    NSLog("Audio Permission not granted11")
                }
            }

        case .denied: // The user has previously denied access.

            NSLog("Audio Permission not granted")
            return
        case .restricted: // The user can't grant access due to restrictions.
            NSLog("Audio Permission Not granted 1")
            return
            default:
            print("ss")
            return
        }
    } else {
        NSLog("OS Version < 10.14")

    }

0 个答案:

没有答案