带有 AVCaptureVideoDataOutput 的 iOS 应用程序在 App Store 版本中崩溃

标签 ios swift xcode avfoundation

我有一个使用相机的应用程序。在上一个版本中,我将相机控制移至一个新类,并且除了第一次运行外,它在 App Store 版本中开始崩溃。通过 Xcode 安装后,该应用程序将按预期运行。

我有以下功能来进行配置。

func performConfiguration(block: @escaping (() -> Void)) {
    sessionQueue.async { () -> Void in
        block()
    }
}

应用程序在我检查是否可以将视频输出添加到 session 中的行崩溃(下面第 6 行):

func configureVideoOutput() {
    performConfiguration { () -> Void in
        self.videoOutput = AVCaptureVideoDataOutput()
        self.videoOutput.setSampleBufferDelegate(self.delegate_voutput, queue: DispatchQueue(label: "sample buffer delegate"))

        if self.session.canAddOutput(self.videoOutput) {
            self.session.addOutput(self.videoOutput)
            let connection = self.videoOutput.connection(with: .video)
            connection?.videoOrientation = .portrait
        }
    }
}

这是 delegate_voutput 代码:

    weak var delegate_voutput: AVCaptureVideoDataOutputSampleBufferDelegate?

我将 View Controller 中的 delegate_voutput 设置为“self”并实现委托(delegate)函数。

这是来自 App Store 的崩溃日志:

0  MyApp                          0x1003b921c closure #1 in CameraController.configureVideoOutput()
1  MyApp                          0x1003b9e90 partial apply for closure #1 in CameraController.performConfiguration(block:)
2  MyApp                          0x1003bd2c8 thunk for @escaping @callee_guaranteed () -> ()
3  libdispatch.dylib              0x192ff8304 _dispatch_call_block_and_release

我已将 NSCameraUsageDescription 添加到 info.plist 以及本地化版本 (InfoPlist.strings),以防这是原因。

我不确定第一次启动时具体是什么,因为硬盘驱动器中没有存储与配置相关的任何内容。

有没有一种方法可以在不提交应用程序供审核的情况下测试应用程序商店的行为? TestFlight 会给出相同的行为吗?

编辑:以下是在 CameraController.swift 中声明 sessionQueue 的方式:

private var sessionQueue = DispatchQueue(label: "com.mikrasya.myapp")

最佳答案

我按照 Apple 的 AVCam 示例代码更改了应用程序的架构,解决了崩溃问题。

为什么 App 在使用 Xcode 安装时一切正常,但在 App Store 版本中崩溃仍然是个谜。

关于带有 AVCaptureVideoDataOutput 的 iOS 应用程序在 App Store 版本中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57022324/

相关文章:

ios - 从 block 内返回查询

ios - 为什么在 Swift 中总是可以访问可选元组的 .0 元素?

ios - 如何为具有动态高度的表格单元格正确设置自动布局?

ios - 为什么我的编译器指令定义无法识别? ( swift )

swift - findAutocompletePredictionsFromQuery 在 Google Places 的 pod 版本 3.5 中似乎不起作用

ios - Parse 推送通知是否非常不可靠?我的只收到了50%

ios - 关闭 UIScrollView 的滚动但保留缩放功能

ios - 为什么这个 dispatch_after 会立即触发?

swift - 我无法启动 Main.storyboard 或 LaunchScreen.storyboard

xcode - 如何仅在链接时有条件地使用静态库