Harrath hichem
Harrath hichem

Reputation: 163

AVCaptureSession startRunning exc_bad_access iOS 10 Swift 3

I'm having an exc_bad_access crash when starting an AVCaptureSession:

        if captureSession.isRunning == false {
           captureSession.startRunning()
        }

Notice: It was working in Swift 2.2. I'm having this crash only after migration to Swift 3. Any idea!

Upvotes: 4

Views: 2114

Answers (2)

MBH
MBH

Reputation: 16609

As @karnett & @zsteed mentioned I had to add the camera privacy description to info.plist

To add it to info.plist source code add those 2 lines:

<key>NSCameraUsageDescription</key>
<string>Allow us to scan images for QRCode.</string>

Or add new string item in the Property list, the key should be

Privacy - Camera Usage Description

and the value will be your description when the user will be asked to give permission for camera. Same as the screenshot below:

enter image description here

This will let the system ask the user whether they allow us to use the camera.

Thank you

Upvotes: 0

karnett
karnett

Reputation: 454

YES! zsteed's answer works

Add to your Info.plist:

<key>NSCameraUsageDescription</key>
<string>Allow us to scan documents and capture images.</string>

Upvotes: 10

Related Questions