iosswiftavfoundationios-simulator

No active and enabled video connection


The crashed console message when a photo is taken is:

[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] No active and enabled video connection`

I've followed the Apple documentation of how to set this up.

  1. Create an AVCapturePhotoOutput object. Use its properties to determine supported capture settings and to enable certain features (for example, whether to capture Live Photos).

fileprivate var photoOutput: AVCapturePhotoOutput!

  1. Create and configure an AVCapturePhotoSettings object to choose features and settings for a specific capture (for example, whether to enable image stabilization or flash).

    photoOutput = AVCapturePhotoOutput()
    if self.session.canAddOutput(photoOutput) {
        self.session.addOutput(photoOutput)
    }
    
  2. Capture an image by passing your photo settings object to the capturePhoto(with:delegate:) method along with a delegate object implementing the AVCapturePhotoCaptureDelegate protocol. The photo capture output then calls your delegate to notify you of significant events during the capture process.

queue.async { self.photoOutput.capturePhoto(with: AVCapturePhotoSettings(), delegate: self) }

But I'm still getting the crash error. Does anyone know why this would be? (I've seen some SO questions that have answer but they're not what works for myself or other, or there's no answer. So I'd be really grateful if anyone knew an answer.) This only happens in the iOS simulator for me, not when I'm testing on device.

I can post any extra needed code, I just didn't want to add too much to start.


Solution

  • The Simulator does not currently have a simulated camera. If this is important to you please file a bug report at https://bugreport.apple.com to request it. In many cases feature priority is informed by developer bug reports and duplicate counts, so filing them is important even if they are duplicates.