CGImageRef is nil?
CGImageRef is nil? I'm trying to take pictures in my app using AVFoundatin. In the didFinishProcessingPhoto block I run some code to gather the image data and create an image to show in the preview screen. Code included below: didFinishProcessingPhoto func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) { if let error = error { print("Error capturing photo: (error)") } else { let photoData = photo.fileDataRepresentation() if let currentData = photoData { let dataProvider = CGDataProvider(data: currentData as CFData) let cgImageRef = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: CGColorRenderingIntent.defaultIntent) let image = UIImage(cgImage: cgImageRef!, scale: 1.0, orientation: self.getImageOrientation(forCamera: self.videoDeviceInput.device.position)) let containerView = PreviewPhotoC...