问题
SwiftPrivate versions of these API by prepending each API with double underscore (__
). For example, change AVCaptureDevice.Format.supportedColorSpaces
to AVCaptureDevice.Format.__supportedColorSpaces
.
参考资料
Undefined symbols for supportedFlashModes in AVCapturePhotoOutput
Apple 回复:AVFoundation capture APIs 用Swift3或4 在Xcode9中被不经意标注成private
AVFoundation API 暂时不能用:
AVCaptureDevice.Format.supportedColorSpaces
AVCaptureDevice.supportedFlashModes
AVCapturePhotoOutput.availablePhotoPixelFormatTypes
AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes
AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes
它在Xcode 12.0中使用模拟器时是有问题的,对真机设备来说,没问你题。
解决方法:
#if targetEnvironment(simulator)
let pixelFormat = photoSettings.__availablePreviewPhotoPixelFormatTypes.first!
#else
let pixelFormat = photoSettings.availablePreviewPhotoPixelFormatTypes.first!
#endif