Using camera with Mac Catalyst

In an app ported to Mac Catalyst, the camera interface always turned out to be blank.

I have checked: the capabilities includes "Camera", the privacy setting in info.plist is there (the iPad app shows the camera fine), and I even try to include front camera for UIImagePickerController.

    if UIImagePickerController.isSourceTypeAvailable(.camera) { 
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .camera
imagePicker.delegate = self
imagePicker.cameraDevice = .front // added for Mac

self.present(imagePicker, animated:true, completion:nil)
}

The error I got is: "[Generic] Could not create video device input: Error Domain=AVFoundationErrorDomain Code=-11814"

Replies

I have no trouble taking a picture using the camera using UIImagePickerController when running my iPad app on a Mac. My code doesn't attempt to set anything on the image picker except the delegate and the sourceType (camera).


Did you check if your app is enable in the privacy settings? Run the System Preferences app on the Mac. Go to Security & Privacy. Then click on the Privacy tab. Select Camera on the left. Is your app showing and enabled?

I am still testing the app with Xcode... the app has not been released, so it shouldn't be in the enabled in Privacy setting right?


Basically the camera window shows up... but it is empty with the error message: "[Generic] Could not create video device input: Error Domain=AVFoundationErrorDomain Code=-11814"

It will appear in the privacy settings the first time the app requests camera access. It doesn't need to be released.

The app did request for camera access, and it is allowed, and the app shows up in privacy setting.


And yet, when the camera UI shows up, it is blank. The red button cannot be clicked, and can only clicked on Cancel button.

Cool