3 Replies
      Latest reply on Oct 21, 2019 2:47 AM by RCPPzaken
      steven88 Level 1 Level 1 (0 points)

        I have an iPad app where we use the camera for scanning QR codes. Works fine for iPad (and iPhone).

         

        I call AVCapureDevice.DiscoverySession to get the available cameras, the same conde in the catalyst build returns 0 elements regardless of whther I fully specify which camera I want or use the default(.video) call. And I have the Privacy description in the info plist.

         

        Anyone else seen this ?

        • Re: iPad app camera access with Catalyst
          RCPPzaken Level 1 Level 1 (10 points)

          I'm having the same issue. I've even tried including all the possible devices but no luck:

                  let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInMicrophone,
                                                                                        .builtInWideAngleCamera,
                                                                                        .builtInTelephotoCamera,
                                                                                        .builtInUltraWideCamera,
                                                                                        .builtInDualCamera,
                                                                                        .builtInDualWideCamera,
                                                                                        .builtInTripleCamera,
                                                                                        .builtInTrueDepthCamera],
                                                                          mediaType: .video,
                                                                          position: .unspecified)
                  print(discoverySession.devices)
          


          Always get 0 devices.

            • Re: iPad app camera access with Catalyst
              jibs Level 1 Level 1 (0 points)

              Yep, same problem here. Below code all returns 0 for devices found. Does anyone have a solution?

               

              import UIKit
              import AVFoundation
              
              class ViewController: UIViewController {
              
                  override func viewDidLoad() {
                      super.viewDidLoad()
                      // Do any additional setup after loading the view.
                      let auth = AVCaptureDevice.authorizationStatus(for: .audio)
                      print("auth: \(auth)")
                     
                      AVCaptureDevice.requestAccess(for: .video) { (isSuccess) in
                          print("isSuccess: \(isSuccess)")
                          let devices = AVCaptureDevice.devices()
                          print("found: \(devices.count)")
              
                          let device = AVCaptureDevice.default(for: .video)
                          print("cap: \(device as Any)")
                         
                          let discover = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera, .builtInTripleCamera], mediaType: nil, position: .unspecified)
                          print("found: \(discover.devices.count)")
              
                      }
                     
                  }
              
              
              }
            • Re: iPad app camera access with Catalyst
              RCPPzaken Level 1 Level 1 (10 points)

              I received an answer from Apple after submitting a feedback ticket:

              This issue behaves as intended.
              We do document that we are not listing devices in Catalyst mode.
              See
              Important iPad apps running in macOS cannot use the AVFoundation Capture classes. These apps should instead use UIImagePickerController for photo and video capture.

               

              Please close your feedback report, or let us know if this is still an issue for you.

              https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture

              So unless they update it in the future it's not possible to access the camera on a Mac from a Catalyst app.