I'm calling a function to attempt to turn on my device's flash:
private func flashOn(device:AVCaptureDevice)
{
print("flashOn called");
do {
try device.lockForConfiguration()
// line below returns warning 'flashMode' was deprecated in iOS 10.0: Use AVCapturePhotoSettings.flashMode instead.
device.flashMode = AVCaptureDevice.FlashMode.auto
device.unlockForConfiguration()
} catch {
// handle error
print("flash on error");
}
}
Setting device.flashMode to AVCaptureDevice.FlashMode.auto brings up the warning "'flashMode' was deprecated in iOS 10.0: Use AVCapturePhotoSettings.flashMode instead.". Even though it is just a warning, it does not enable the flash when testing my app, so I change that line to:
device.flashMode = AVCaptureDevice.FlashMode.auto
So I set the line to this, like it suggests:
AVCapturePhotoSettings.flashMode = AVCaptureDevice.FlashMode.auto
And I get the error "Instance member 'flashMode' cannot be used on type 'AVCapturePhotoSettings'"
So I have no idea how to set the flash in Xcode version 9 using Swift 4.0. All the answers I've found in Stack Overflow have been for previous versions.