Xcode 12 beta 6中缺少availableRawPhotoPixelFormatTypes

问题描述

我得到以下代码段:

let newPhotoSettings = AVCapturePhotoSettings(rawPixelFormatType: OSType(self.photoOutput.availableRawPhotoPixelFormatTypes.first!),processedFormat: nil)

在Xcode 12 beta 6中构建时,出现以下错误

Value of type 'AVCapturePhotoOutput' has no member 'availableRawPhotoPixelFormatTypes'

当我查看api文档here)时,它没有显示availableRawPhotoPixelFormatTypes 已弃用。

还有其他人遇到这个问题吗?

更新

以上错误仅在我尝试为主屏幕小部件呈现SwiftUI预览时出现。如果我正常运行该项目,那么它将运行正常且没有错误

此外,对于预览像素类型,我也遇到相同的错误

photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: photoSettings.availablePreviewPhotoPixelFormatTypes[0]]

Value of type 'AVCapturePhotoSettings' has no member 'availablePreviewPhotoPixelFormatTypes'

解决方法

看来这现在分为两个查询:

使用availableRawPhotoFileTypes获取受支持的RAW文件类型,选择其中一种,然后使用supportedRawPhotoPixelFormatTypes(for fileType: AVFileType)询问相应的受支持的格式类型。

我认为,iOS目前仅支持DNG文件,但分离API可能更适合未来。