Issue: ARKit Camera Frame Provider Not Authorized in visionOS App

I’m developing a visionOS app using EnterpriseKit, and I need access to the main camera for QR code detection. I’m using the ARKit CameraFrameProvider and ARKitSession to capture frames, but I’m encountering this error when trying to start the camera stream:

ar_camera_frame_provider_t: Failed to start camera stream with error: <ar_error_t Error Domain=com.apple.arkit Code=100 "App not authorized.">

Context:

  • VisionOS using EnterpriseKit for camera access and QR code scanning.
  • My Info.plist includes necessary permissions like NSCameraUsageDescription and NSWorldSensingUsageDescription.
  • I’ve added the com.apple.developer.arkit.main-camera-access.allow entitlement as per the official documentation here.
  • My app is allowed camera access as shown in the logs (Authorization status: [cameraAccess: allowed]), but the camera stream still fails to start with the “App not authorized” error.
  • I followed Apple’s WWDC 2024 sample code for accessing the main camera in visionOS from this session.

Sample of My Code:

import ARKit
import Vision

class QRCodeScanner: ObservableObject {
    private var arKitSession = ARKitSession()
    private var cameraFrameProvider = CameraFrameProvider()
    private var pixelBuffer: CVPixelBuffer?

    init() {
        Task {
            await requestCameraAccess()
        }
    }

    private func requestCameraAccess() async {
        await arKitSession.queryAuthorization(for: [.cameraAccess])
        do {
            try await arKitSession.run([cameraFrameProvider])
        } catch {
            print("Failed to start ARKit session: \(error)")
            return
        }
        
        let formats = CameraVideoFormat.supportedVideoFormats(for: .main, cameraPositions: [.left])
        guard let cameraFrameUpdates = cameraFrameProvider.cameraFrameUpdates(for: formats[0]) else { return }

        Task {
            for await cameraFrame in cameraFrameUpdates {
                guard let mainCameraSample = cameraFrame.sample(for: .left) else { continue }
                self.pixelBuffer = mainCameraSample.pixelBuffer
                // QR Code detection code here
            }
        }
    }
}

Things I’ve Tried:

  • Verified entitlements in both Info.plist and .entitlements files. I have added the com.apple.developer.arkit.main-camera-access.allow entitlement.
  • Confirmed camera permissions in the privacy settings.
  • Followed the official documentation and WWDC 2024 sample code.
  • Checked my provisioning profile to ensure it supports ARKit camera access.

Request:

Has anyone encountered this “App not authorized” error when accessing the main camera via ARKit in visionOS using EnterpriseKit? Are there additional entitlements or provisioning profile configurations I might be missing? Any help would be greatly appreciated! I haven't seen any official examples using new API for main camera access and no open source examples either.

I am having the same issue in my project :(

@nataodutton and @NikStiresLLAR

This post and this post cover a similar issue and have some useful troubleshooting tips.

Please let me know how this turns out!

@nataodutton and @NikStiresLLAR I'm running into the same issue with spatial barcode scanning. Have you come across any solutions for this?

I have faced the same issue and it is very weird it starts working if you do the same in an immersive window. I have no clue why

This earlier post happens to mention that ARKit only runs in an immersive space.

Apparently this means that the front camera can only be used in an immersive window? Can anyone from Apple confirm this?

I am running code in an immersive space and still getting the "app not authorized" error. Here is my code:

import RealityKit
import ARKit

struct ImmersiveView: View {
    @State private var arkitSession = ARKitSession()
    @State private var cameraAccessStatus: String = "Checking camera access..."
    @State private var frameCount = 0
    @State private var pixelBuffer: CVPixelBuffer?

    var body: some View {
        RealityView { realityView in
            // Perform setup directly in RealityView
            Task {
                await setupARKitSession()
            }
        }
        .edgesIgnoringSafeArea(.all)
        .overlay(alignment: .top) {
            VStack {
                Text(cameraAccessStatus)
                    .font(.headline)
                    .foregroundColor(cameraAccessStatus == "Frames are displaying!" ? .green : .red)
                Text("Frames processed: \(frameCount)")
                    .font(.subheadline)
            }
            .padding()
            .background(Color.black.opacity(0.7))
            .cornerRadius(10)
        }
    }

    private func setupARKitSession() async {
        let cameraFrameProvider = CameraFrameProvider()

        do {
            cameraAccessStatus = "Initializing ARKit session..."
            print ("Initializing ARKit session...")
            try await arkitSession.run([cameraFrameProvider])

            let formats = CameraVideoFormat.supportedVideoFormats(for: .main, cameraPositions: [.left])
            guard let highResolutionFormat = formats.max(by: { $0.frameSize.height < $1.frameSize.height }),
                  let cameraFrameUpdates = cameraFrameProvider.cameraFrameUpdates(for: highResolutionFormat) else {
                print("Failed to start camera.")
                cameraAccessStatus = "Failed to start camera."
                return
            }

            print ("cameraFrameUpdates initialized successfully")
            cameraAccessStatus = "Frames are coming!"

            for await frame in cameraFrameUpdates {
                if let sample = frame.sample(for: .left) {
                    DispatchQueue.main.async {
                        pixelBuffer = sample.pixelBuffer
                        frameCount += 1
                        print("Frame \(frameCount) received.")
                    }
                }
            }
        } catch {
            cameraAccessStatus = "Failed to start ARKit: \(error.localizedDescription)"
        }
    }
}


And here is the console output:

```Initializing ARKit session...

cannot add handler to 0 from 1 - dropping

cameraFrameUpdates initialized successfully

ar_camera_frame_provider_t <0x3011079f0>: Failed to start camera stream with error: <ar_error_t: 0x30238b060 Error Domain=com.apple.arkit Code=100 "App not authorized." UserInfo={NSLocalizedFailureReason=Using camera frame provider requires an entitlement., NSLocalizedRecoverySuggestion=, NSLocalizedDescription=App not authorized.}>

I checked entitlements with the codesign command and it looks like my app is correctly entitled:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>application-identifier</key><string>Z9FYRK8P89.com.imeve.avpenterprisetest</string><key>com.apple.developer.arkit.main-camera-access.allow</key><true/><key>com.apple.developer.screen-capture.include-passthrough</key><true/><key>com.apple.developer.team-identifier</key><string>Z9FYRK8P89</string><key>get-task-allow</key><true/></dict></plist>

Issue: ARKit Camera Frame Provider Not Authorized in visionOS App
 
 
Q