Xcode 12. 'AVCapturePhotoOutput' 类型的值没有成员 'supportedFlashModes'
Xcode 12. Value of type 'AVCapturePhotoOutput' has no member 'supportedFlashModes'
在新的 Xcode 12 中,出现错误:Value of type 'AVCapturePhotoOutput' has no member 'supportedFlashModes'
当我尝试到达 https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/1648766-supportedflashmodes
有什么建议吗?
似乎是 Xcode 12 上的错误,但您可以使用宏条件解决它:
#if !targetEnvironment(simulator)
guard stillImageOutput?.supportedFlashModes.contains(mode) == true else { return }
//rest of your code
#endif
正如@Andy Heard wrote:
Our apologies. For apps using Swift 3.2 or Swift 4.0, several
AVFoundation capture APIs (public extensions on external protocol)
were inadvertently marked private in Xcode 9.
The following AVFoundation API are temporarily unavailable:
AVCaptureDevice.Format.supportedColorSpaces
AVCaptureDevice.supportedFlashModes
AVCapturePhotoOutput.availablePhotoPixelFormatTypes
AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes
AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes
As a workaround you can use the SwiftPrivate versions of these API by
prepending each API with double underscore (__
). For example, change
AVCaptureDevice.Format.supportedColorSpaces
to
AVCaptureDevice.Format.__supportedColorSpaces
.
对于XCode 12回归(叹息),你可以像这样使用__版本
var flashModesSupported: [AVCaptureDevice.FlashMode] {
#if targetEnvironment(simulator)
return self.photoOutput.__supportedFlashModes.compactMap { AVCaptureDevice.FlashMode.init(rawValue: [=10=].intValue) }
#else
return self.photoOutput.supportedFlashModes
#endif
}
有一份报告没有触发 SPI(因此,可以安全地提交到应用商店)
你可以试试这个:
let device2 = AVCapturePhotoOutput()
if (device2.supportedFlashModes.contains(.auto)){
} else {
}
在新的 Xcode 12 中,出现错误:Value of type 'AVCapturePhotoOutput' has no member 'supportedFlashModes'
当我尝试到达 https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/1648766-supportedflashmodes
有什么建议吗?
似乎是 Xcode 12 上的错误,但您可以使用宏条件解决它:
#if !targetEnvironment(simulator)
guard stillImageOutput?.supportedFlashModes.contains(mode) == true else { return }
//rest of your code
#endif
正如@Andy Heard wrote:
Our apologies. For apps using Swift 3.2 or Swift 4.0, several AVFoundation capture APIs (public extensions on external protocol) were inadvertently marked private in Xcode 9.
The following AVFoundation API are temporarily unavailable:
AVCaptureDevice.Format.supportedColorSpaces
AVCaptureDevice.supportedFlashModes
AVCapturePhotoOutput.availablePhotoPixelFormatTypes
AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes
AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes
As a workaround you can use the SwiftPrivate versions of these API by prepending each API with double underscore (
__
). For example, changeAVCaptureDevice.Format.supportedColorSpaces
toAVCaptureDevice.Format.__supportedColorSpaces
.
对于XCode 12回归(叹息),你可以像这样使用__版本
var flashModesSupported: [AVCaptureDevice.FlashMode] {
#if targetEnvironment(simulator)
return self.photoOutput.__supportedFlashModes.compactMap { AVCaptureDevice.FlashMode.init(rawValue: [=10=].intValue) }
#else
return self.photoOutput.supportedFlashModes
#endif
}
有一份报告没有触发 SPI(因此,可以安全地提交到应用商店)
你可以试试这个:
let device2 = AVCapturePhotoOutput()
if (device2.supportedFlashModes.contains(.auto)){
} else {
}