title: device.makeCommandQueue() gives Fatal error: Unexpectedly found nil while unwrapping an Optional value
body: <p>This line</p>
  
  <pre><code>commandQueue = device.makeCommandQueue()  
  </code></pre>
  
  <p>gives runtime error</p>
  
  <pre><code>Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value 
  </code></pre>
  
  <p><br></p>
  
  <pre><code>import UIKit
  import MetalKit
  
  enum Colors{
      static let ClearColor = MTLClearColor(red: 0.0,
                                            green: 0.21,
                                            blue: 0.4,
                                            alpha: 1.0)
  }
  
  class ViewController: UIViewController {
  
      var metalView: MTKView{
          return view as! MTKView
      }
  
      var device: MTLDevice!
      var commandQueue: MTLCommandQueue!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          metalView.device = MTLCreateSystemDefaultDevice()
          device = metalView.device
  
          metalView.clearColor = Colors.ClearColor
  
          commandQueue = device.makeCommandQueue()
          let commandBuffer = commandQueue.makeCommandBuffer()
  
          let commandEncoder =
            commandBuffer?.makeRenderCommandEncoder(descriptor: metalView.currentRenderPassDescriptor!)
  
          commandEncoder?.endEncoding()
          commandBuffer?.present(metalView.currentDrawable!)
          commandBuffer?.commit()
      }
  
  }
  </code></pre>