1

The main example https://gist.github.com/C4Tutorials/5399635 crashes in the simulator with the following error: NSInvalidArgumentException', reason: '*** Can't add a nil AVCaptureInput'

It does work when launched on hardware. Is this a known issue or is there a workaround?

Adam Tindale
  • 1,239
  • 10
  • 26
  • 1
    You can't use the simulator for the camera. This is an iOS / Simulator issue, you always need to have a device for working with the camera. – C4 - Travis Oct 28 '13 at 21:05
  • 1
    possible duplicate of [How do I test a camera in the iPhone simulator?](http://stackoverflow.com/questions/2168484/how-do-i-test-a-camera-in-the-iphone-simulator) – Adam Tindale Oct 29 '13 at 02:53

1 Answers1

2

i think you can prevent the crash by checking the availability of the AVCaptureInput object before you add it to the AVCaptureSession.

to simplify it check the below code this will prevent the crash on the simulator but it won't help you test it.

try to find where ever you add a AVCaptureInput to a AVCaptureSession and put the following piece of code .

if ([session canAddInput: backCameraDeviceInput])
{
    [session addInput: backCameraDeviceInput];
}

i wish this was helpful :)

Ahmad Al-Attal
  • 435
  • 4
  • 13