In new Xcode 12, there is an error: Value of type 'AVCapturePhotoOutput' has no member 'supportedFlashModes'
when i try to reach https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/1648766-supportedflashmodes
Any suggestions?

- 12,630
- 8
- 75
- 122
-
1I'm having the same issue. Looks like it could have accidentally marked as private looking at this post: https://developer.apple.com/forums/thread/86810 – Andy Heard Sep 18 '20 at 11:31
4 Answers
Seems to be a bug on Xcode 12, but you can workaround it using macro conditions:
#if !targetEnvironment(simulator)
guard stillImageOutput?.supportedFlashModes.contains(mode) == true else { return }
//rest of your code
#endif

- 367
- 2
- 9
-
-
I still get the error. `backCamera.hasFlash && self.stillImageOutput.supportedFlashModes.contains(mode)` – King Sep 24 '20 at 11:37
-
`mode` is an `AVCaptureDevice.FlashMode` value, it's just an example. – bguidolim Sep 24 '20 at 15:03
As @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
.

- 12,630
- 8
- 75
- 122
For the XCode 12 regression (sigh), you can use the __ version like so
var flashModesSupported: [AVCaptureDevice.FlashMode] {
#if targetEnvironment(simulator)
return self.photoOutput.__supportedFlashModes.compactMap { AVCaptureDevice.FlashMode.init(rawValue: $0.intValue) }
#else
return self.photoOutput.supportedFlashModes
#endif
}
There was a report this did not trigger SPI (so, safe to submit to app store)

- 6,392
- 2
- 37
- 45
You can try this:
let device2 = AVCapturePhotoOutput()
if (device2.supportedFlashModes.contains(.auto)){
} else {
}

- 2,051
- 4
- 14
- 32

- 191
- 1
- 5