Xcode 8升级到XCode 9后报错"Type 'AVCapturePhotoOutput' does not conform to protocol 'AVCapturePhotoOutputType'"怎么解决?

标签: Xcode Swift
发布时间: 2018/1/2 15:27:39
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

我有一个照相APP,在xcode8能正常运行,可是升级到xcode9后就报错了:

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

具体错误信息:

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

怎么解决?

解决方法 1:

只要替换你的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)
}


官方微信
官方QQ群
31647020