我有一个使用相机的应用程序。在上一个版本中,我将相机控制移至一个新类,并且除了第一次运行外,它在 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/