Ypimagepicker: Value of type 'AVCapturePhotoOutput' has no member 'supportedFlashModes'

Created on 29 Aug 2020  路  11Comments  路  Source: Yummypets/YPImagePicker

I am having this error on PostiOS10PhotoCapture.swift

if let deviceInput = deviceInput {
            if deviceInput.device.isFlashAvailable {
                switch currentFlashMode {
                case .auto:
                    if photoOutput.supportedFlashModes.contains(.auto) {
                        settings.flashMode = .auto
                    }
                case .off:
                    if photoOutput.supportedFlashModes.contains(.off) {
                        settings.flashMode = .off
                    }
                case .on:
                    if photoOutput.supportedFlashModes.contains(.on) {
                        settings.flashMode = .on
                    }
                }
            }
        }

Any idea?

Xcode12 / iOS14

Most helpful comment

I think can use this code.

// Set flash mode.
if let deviceInput = deviceInput, let supportedFlashModes = photoOutput.value(forKey: "supportedFlashModes") as? [Int] {
    if deviceInput.device.isFlashAvailable {
        switch currentFlashMode {
        case .auto:
            if supportedFlashModes.contains(AVCaptureDevice.FlashMode.auto.rawValue) {
                settings.flashMode = .auto
            }
        case .off:
            if supportedFlashModes.contains(AVCaptureDevice.FlashMode.off.rawValue) {
                settings.flashMode = .off
            }
        case .on:
            if supportedFlashModes.contains(AVCaptureDevice.FlashMode.on.rawValue) {
                settings.flashMode = .on
            }
        }
    }
}

you can see the pull request at : https://github.com/Yummypets/YPImagePicker/pull/565

All 11 comments

I think this is xcode 12 beta 6 bug.

How to fix this ? any idea ?

I'm having the same issue with Xcode 12 beta 6...

wait for next release of xcode 12,馃槄

same error on Xcode 12.0 GM (Simulator)
working on device

I think can use this code.

// Set flash mode.
if let deviceInput = deviceInput, let supportedFlashModes = photoOutput.value(forKey: "supportedFlashModes") as? [Int] {
    if deviceInput.device.isFlashAvailable {
        switch currentFlashMode {
        case .auto:
            if supportedFlashModes.contains(AVCaptureDevice.FlashMode.auto.rawValue) {
                settings.flashMode = .auto
            }
        case .off:
            if supportedFlashModes.contains(AVCaptureDevice.FlashMode.off.rawValue) {
                settings.flashMode = .off
            }
        case .on:
            if supportedFlashModes.contains(AVCaptureDevice.FlashMode.on.rawValue) {
                settings.flashMode = .on
            }
        }
    }
}

you can see the pull request at : https://github.com/Yummypets/YPImagePicker/pull/565

this is confirmed still broken in xcode 12 official release

I was able to fix this temporarily by deleting this code, which my project doesn't need anyway :)

if let deviceInput = deviceInput {
            if deviceInput.device.isFlashAvailable {
                switch currentFlashMode {
                case .auto:
                    if photoOutput.supportedFlashModes.contains(.auto) {
                        settings.flashMode = .auto
                    }
                case .off:
                    if photoOutput.supportedFlashModes.contains(.off) {
                        settings.flashMode = .off
                    }
                case .on:
                    if photoOutputsupportedFlashModes.contains(.on) {
                        settings.flashMode = .on
                    }
                }
            }
        }

@NikKovIos Hi, any chance of having a new release which can be used with latest Xcode 12?

We've created a fork which comments out this section of code and so allows building with Xcode 12 gm here: https://github.com/bikemap/YPImagePicker - feel free use this fork as a workaround until the issue is resolved here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

esabunor picture esabunor  路  5Comments

Berk-Kaya picture Berk-Kaya  路  3Comments

jonnyarc picture jonnyarc  路  3Comments

rajabpour picture rajabpour  路  3Comments

DamascenoRafael picture DamascenoRafael  路  5Comments