ios - 将 Xcode 8 升级到 XCode 9 后出现 AvCapture 错误

标签 ios swift xcode camera avcapturesession

我正在处理另一位开发人员的代码,它是一个相机应用程序。我对其进行了研究,在升级到 xCode 9 之前它运行良好。下面是代码片段

@objc protocol AVCapturePhotoOutputType {
@available(iOS 10.0, *)
var isLensStabilizationDuringBracketedCaptureSupported: Bool {get}
@available(iOS 10.0, *)
var availableRawPhotoPixelFormatTypes: [Int] {get}
@available(iOS 10.0, *)
var isHighResolutionCaptureEnabled: Bool {get 
@objc(setHighResolutionCaptureEnabled:) set}
@available(iOS 10.0, *)
var supportedFlashModes: [Int] {get}
@available(iOS 10.0, *)
func connection(withMediaType mediaType: String!) -> AVCaptureConnection!
@available(iOS 10.0, *)
@objc(capturePhotoWithSettings:delegate:)
func capturePhoto(with settings: AVCapturePhotoSettings, delegate: 
AVCapturePhotoCaptureDelegate)}

@available(iOS 10.0, *)
extension AVCapturePhotoOutput:AVCapturePhotoOutputType {}

现在我在行扩展 AVCapturePhotoOutput:AVCapturePhotoOutputType {} 上遇到错误,即扩展协议(protocol)。这是错误

Type 'AVCapturePhotoOutput' does not conform to protocol 'AVCapturePhotoOutputType'

xCode 还提供自动修复选项,当我应用生成两个 stub 时,我开始收到错误,如下图所示。

Errors after adding stubs

我不明白为什么升级到 xCode 9 后会发生这种情况,任何帮助将不胜感激。

最佳答案

我遇到了完全相同的问题。只需用此协议(protocol)替换您的协议(protocol)即可

@objc protocol AVCapturePhotoOutputType {
@available(iOS 10.0, *)
var isLensStabilizationDuringBracketedCaptureSupported: Bool {get}
//### `availableRawPhotoPixelFormatTypes` is temporarily renamed to `__availableRawPhotoPixelFormatTypes`,
//### Maybe more Swiftish refinement is planned, but not yet completed.
@available(iOS 10.0, *)
@objc(availableRawPhotoPixelFormatTypes)
var __availableRawPhotoPixelFormatTypes: [NSNumber] {get}
@available(iOS 10.0, *)
var isHighResolutionCaptureEnabled: Bool {get @objc(setHighResolutionCaptureEnabled:) set}
@available(iOS 10.0, *)
//### `supportedFlashModes` is temporarily renamed to `__supportedFlashModes`,
//### Maybe more Swiftish refinement is planned, but not yet completed.
@objc(supportedFlashModes)
var __supportedFlashModes: [NSNumber] {get}
@available(iOS 10.0, *)
@objc(connectionWithMediaType:)
func connection(with mediaType: AVMediaType) -> AVCaptureConnection?
@available(iOS 10.0, *)
@objc(capturePhotoWithSettings:delegate:)
func capturePhoto(with settings: AVCapturePhotoSettings, delegate: AVCapturePhotoCaptureDelegate)
}

干杯:-)

关于ios - 将 Xcode 8 升级到 XCode 9 后出现 AvCapture 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48023849/

相关文章:

ios - 理解 swift Alamofire completionHandler

ios - 在 iOS 中从服务器更新应用程序资源

ios - 验证远程代理配置 'vs-mda-remote test' 失败并显示 'Error: not enough data' 时出错

ios - 在函数 Swift 中访问数组的 indexPath

ios - swift 中的 C 数组内存释放

swift - 使结构可哈希?

ios - 如何制作一个自动调整的UiTextField Frame

用于嵌入式 Linux 内核开发的 XCode 4?

iOS 编译库/框架链接器标记为设备而非模拟器编译的问题

ios - 在 React Native 初始化项目中为 iOS 设置 Facebook SDK 时使用未声明的标识符