title: Error when instantiating AVCaptureDeviceInput
body: <p>I'm building an app with a bottom bar that has different views.
  An RSS feed view opened by the bottom left corner button and a custom camera from the bottom right corner button.
  By compiling the app and running it in the simulator, when I tap on the camera button, the app freezes and on the line             </p>
  
  <pre><code>let captureDeviceInput = try AVCaptureDeviceInput(device: captureDevice)
  </code></pre>
  
  <p>Xcode shows the following error: </p>
  
  <blockquote>
    <p>Thread 1: Fatal error: Unexpectedly found nil while unwrapping an
    Optional value.</p>
  </blockquote>
  
  <p>This is the function:</p>
  
  <pre><code> func beginSession () {
          do {
              let captureDeviceInput = try AVCaptureDeviceInput(device: captureDevice)
  
              captureSession.addInput(captureDeviceInput)
  
          }catch {
              print(error.localizedDescription)
          }
  </code></pre>
  
  <p>How can I fix the issue? Thank you!</p>