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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将Xcode 8升级到XCode 9后出现AvCapture错误相关的知识,希望对你有一定的参考价值。

我正在研究另一个开发人员的代码,它是一个相机应用程序。我已经完成了它并且在升级到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 {}即扩展协议。这是错误

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

xCode也提供自动修复选项,当我申请生成两个存根时,我开始收到错误,如下图所示。

Errors after adding stubs

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

答案

我有完全相同的问题。只需用此协议替换您的协议即可

@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)
}

欢呼:-)

以上是关于将Xcode 8升级到XCode 9后出现AvCapture错误的主要内容,如果未能解决你的问题,请参考以下文章

xcodebuild:使用升级到 XCode 8.1 后出现“需要代码签名”错误

升级到 Xcode 8 后出现 GCC 5.4 链接器错误

Xcode 9.2升级导致此错误:“命令/ bin / sh失败,退出代码为1”

升级到 xcode 7 后出现代码问题

将 Xcode 7.3.1 项目升级到 Xcode 8.0

xcode7.3 升级 xcode8.0 后权限设置问题(升级xcode 8.0 后构建版本不显示问题)