Issues setting up the Enterprise API entitlements (Main Camera Access)

Hello, i've recently received the entitlements to access the main camera stream for a project on the Apple Vision Pro.

What happens :

When executing code from this WWDC tutorial , i'm getting this error when trying to use a Camera Frame Provider :

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

What I've tried :

I followed the instructions given by mail, by :

  • adding the .license file at the root of my project,

  • adding the .entitlements file by adding capabilities in the project (Main Camera Access & Passthrough in screen capture are there).

  • I've added NSCameraDescription, NSEnterpriseMCAMUsageDescription and NSWorldSensingUsageDescription (they all have a value assigned).

  • I've also followed those post & post advices.

  • When checking on the Account settings, i do see the capabilities in the "additional capabilities"

On first launch, I'm also getting prompted to accept the NSEnterpriseMCAMUsageDescription, so I assume the info.plist file is valid?

What did i missed to get the entitlements working ?

Here's the code :

import ARKit
import SwiftUI
import Vision
import RealityKit
    
class MainCameraAccess {
    var arKitSession = ARKitSession()
    var cameraFrameProvider = CameraFrameProvider()
    var pixelBuffer: CVPixelBuffer?
    
    func startCameraSession() async {
        let formats = CameraVideoFormat.supportedVideoFormats(for: .main, cameraPositions: [.left])

        // Request authorization
        await arKitSession.requestAuthorization(for: [.cameraAccess])

        // Start the session
        do {
            try await arKitSession.run([cameraFrameProvider])
        } catch {
            print("Failed to start ARKit session: \(error)")
            return
        }

        // Get camera frame updates
        guard let cameraFrameUpdates = cameraFrameProvider.cameraFrameUpdates(for: formats[0]) else {
            return
        }

        // Process frames
        for await cameraFrame in cameraFrameUpdates {
            guard let mainCameraSample = cameraFrame.sample(for: .left) else {
                continue
            }
            self.pixelBuffer = mainCameraSample.pixelBuffer
        }
    }

    func saveLatestImage() {
        guard let pixelBuffer = self.pixelBuffer else {
            print("No image available to save.")
            return
        }

        // Convert CVPixelBuffer to UIImage
        let ciImage = CIImage(cvPixelBuffer: pixelBuffer)
        let context = CIContext()
        guard let cgImage = context.createCGImage(ciImage, from: ciImage.extent) else {
            print("Failed to create CGImage.")
            return
        }
        let uiImage = UIImage(cgImage: cgImage)

        // Save UIImage to Photos Album
        UIImageWriteToSavedPhotosAlbum(uiImage, nil, nil, nil)
        print("Image saved to photo library.")
    }
}

Thanks in advance for the help,

Jeremy

Hi @MrCubic

That code should work. A few things to check:

Having the same issue.

  • I have the Enterprise API license added to my file and assigned to the build target.
  • I have the com.apple.developer.screen-capture.include-passthrough and com.apple.developer.arkit.main-camera-access-allow entitlements.
  • I have NSEnterpriseMCAMUsageDescription, NSCameraUsageDescription, and NSScreenCaptureUsageDescription entries in my plist.

I can create a CameraFrameProvider but as soon as I ask for CameraFrameUpdates I get this error, same as :

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

Issues setting up the Enterprise API entitlements (Main Camera Access)
 
 
Q