0

AVCaptureVideoPreviewLayer crashes when running on simulator now.

Not possible to set the session.

var session: AVCaptureSession? {
    get{
        return (self.layer as! AVCaptureVideoPreviewLayer).session
    }
    set(session) {
        (self.layer as! AVCaptureVideoPreviewLayer).session = session
    }
}
WYS
  • 1,637
  • 2
  • 16
  • 37

2 Answers2

0

Try running your application on an actual device instead of simulator. The AVCaptureVideoPreviewLayer session cannot be captured on simulator.

Vikram Parimi
  • 777
  • 6
  • 29
  • It works on the actual device. But it is sometimes convenient to have it running on the simulator. It worked on the previous Xcode. – WYS Oct 05 '16 at 11:57
0

Fix the crash here by checking like

 if let captureDevice = AVCaptureDevice.default(for: AVMediaType.video) {
    // init AVCaptureSession here
 }
Kathiresan Murugan
  • 2,783
  • 3
  • 23
  • 44