title: AVCaptureDevice flashMode not working
body: <p>In an app using <code>AVCaptureSession</code> and <code>AVCaptureDevice</code>, I am taking pictures and it goes as expected.</p>
  
  <p>I decided to implement the use of the flash and there troubles are coming.</p>
  
  <p>Here is the code I added, after searching on the net on how to use the flash in an iOS app:</p>
  
  <pre><code>    if captureDevice.hasFlash &amp;&amp; captureDevice.isFlashModeSupported(.On) {
          do {try captureDevice.lockForConfiguration()
          } catch let error as NSError {
              print("captureDevice.lockForConfiguration FAILED")
              print(error.code)
          }
          captureDevice.flashMode = .On
          captureDevice.unlockForConfiguration()
          captureSession.commitConfiguration()
      }
  </code></pre>
  
  <p>It compiles OK but when I try to take a photo, the app crashes with the following error:</p>
  
  <pre><code>Error on taking a picture:
  Error Domain=AVFoundationErrorDomain Code=-11800 "The operation couldn’t be completed." UserInfo={NSUnderlyingError=0x14e176f40 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}, NSLocalizedFailureReason=Undefined error（-16800）, NSLocalizedDescription=The operation couldn’t be completed.}
  </code></pre>
  
  <p>Since I have never used the flash before, it may well be a newbie error. But I haven’t, at this point, been able to figure out what was wrong.
  If anyone has experience using the flash in an app, please let me know what may be the issue.</p>