Swift 相机方向设定demo错误

        if let videoLayer = AVCaptureVideoPreviewLayer.init(session: captureSession) {

            videoLayer.frame = (cameraPreviewLayer?.bounds)!
            //            videoLayer.frame = (bone_image.bounds)

            videoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
            videoLayer.connection.videoOrientation = .landscapeRight
            cameraPreviewLayer?.addSublayer(videoLayer)
        }

    }

错误代码

if let videoLayer = AVCaptureVideoPreviewLayer.init(session: captureSession) 

报错内容:
Initializer for conditional binding must have Optional type, not 'AVCaptureVideoPreviewLayer'

这网上也查了资料,不用init也是这样的错误,我借鉴的demo却能成功。
哪个大神来看看出了什么问题吗

我用的是Xcode 9.2
swift 4
iOS 11.4

https://stackoverflow.com/questions/46723783/initializer-for-conditional-binding-must-have-optional-type-not-avcapturevideo