RobertJoseph RobertJoseph - 1 year ago 1568
Swift Question

Swift 3.0, Xcode 8 Beta 2: AVCaptureDevice.requestAccess() crash

I created an iOS single view application using Swift 3.0 and Xcode 8 Beta 2. I am linking with the


This is my view controller code:

import UIKit
import AVFoundation

class ViewController: UIViewController {

override func viewDidLoad() {

if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == .notDetermined {
AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { (granted: Bool) in
if granted {
else {
print("not granted")

When I run this on my device the app crashes after executing the
line (the completion handler is not executed and no exceptions are thrown).

The only thing in the Console is:

2016-07-15 14:55:44.621819 testpp[2261:912051] [MC] System group container for path is /private/var/containers/Shared/SystemGroup/
2016-07-15 14:55:44.626012 testpp[2261:912051] [MC] Reading from public effective user settings.
2016-07-15 14:55:59.284610 testpp[2261:912085] [access] <private>

Am I doing something wrong?

Answer Source

Make sure you set a value for the Privacy - Camera Usage Description key in your Info.plist file when requesting camera access.