Microphone Class Use Causes Xcode Build Failure

I have found that having code referencing the Unity Microphone class in a project successfully builds an Xcode project but the Xcode project will fail to compile due to code in AVCapture.mm. Below are the errors that I get from the Xcode project build steps:

Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:22:24: error: 'AVAuthorizationStatusAuthorized' is unavailable: not available on visionOS
    NSInteger status = AVAuthorizationStatusAuthorized;
                       ^
In file included from /Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:3:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFCapture.h:11:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDataOutputSynchronizer.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutput.h:12:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureAudioDataOutput.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutputBase.h:13:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h:11:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1863:28: note: 'AVAuthorizationStatus' has been explicitly marked unavailable here
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
                           ^
/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:23:15: error: 'AVCaptureDevice' is unavailable: not available on visionOS
    status = [AVCaptureDevice authorizationStatusForMediaType: mediaType];
              ^
In file included from /Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:3:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFCapture.h:11:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDataOutputSynchronizer.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutput.h:12:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureAudioDataOutput.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutputBase.h:13:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h:11:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:72:12: note: 'AVCaptureDevice' has been explicitly marked unavailable here
@interface AVCaptureDevice : NSObject
           ^
/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:23:31: error: 'authorizationStatusForMediaType:' is unavailable: not available on visionOS
    status = [AVCaptureDevice authorizationStatusForMediaType: mediaType];
                              ^
In file included from /Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:3:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFCapture.h:11:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDataOutputSynchronizer.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutput.h:12:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureAudioDataOutput.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutputBase.h:13:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h:11:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1887:1: note: 'authorizationStatusForMediaType:' has been explicitly marked unavailable here
+ (AVAuthorizationStatus)authorizationStatusForMediaType:(AVMediaType)mediaType API_AVAILABLE(macos(10.14), ios(7.0), macCatalyst(14.0), tvos(17.0)) API_UNAVAILABLE(visionos);
^
/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:25:19: error: 'AVAuthorizationStatusNotDetermined' is unavailable: not available on visionOS
    if (status == AVAuthorizationStatusNotDetermined)
                  ^
In file included from /Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:3:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFCapture.h:11:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDataOutputSynchronizer.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutput.h:12:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureAudioDataOutput.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutputBase.h:13:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h:11:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1863:28: note: 'AVAuthorizationStatus' has been explicitly marked unavailable here
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
                           ^
/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:27:24: error: 'AVAuthorizationStatusAuthorized' is unavailable: not available on visionOS
    else if (status == AVAuthorizationStatusAuthorized)
                       ^
In file included from /Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:3:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFCapture.h:11:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDataOutputSynchronizer.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutput.h:12:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureAudioDataOutput.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutputBase.h:13:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h:11:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1863:28: note: 'AVAuthorizationStatus' has been explicitly marked unavailable here
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {
                           ^
/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:41:6: error: 'AVCaptureDevice' is unavailable: not available on visionOS
    [AVCaptureDevice requestAccessForMediaType: mediaType completionHandler:^(BOOL granted) {
     ^
In file included from /Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:3:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFCapture.h:11:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDataOutputSynchronizer.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutput.h:12:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureAudioDataOutput.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutputBase.h:13:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h:11:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:72:12: note: 'AVCaptureDevice' has been explicitly marked unavailable here
@interface AVCaptureDevice : NSObject
           ^
/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:41:22: error: 'requestAccessForMediaType:completionHandler:' is unavailable: not available on visionOS
    [AVCaptureDevice requestAccessForMediaType: mediaType completionHandler:^(BOOL granted) {
                     ^
In file included from /Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:3:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:23:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFCapture.h:11:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDataOutputSynchronizer.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutput.h:12:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureAudioDataOutput.h:10:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureOutputBase.h:13:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h:11:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator1.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1910:1: note: 'requestAccessForMediaType:completionHandler:' has been explicitly marked unavailable here
+ (void)requestAccessForMediaType:(AVMediaType)mediaType completionHandler:(void (^)(BOOL granted))handler API_AVAILABLE(macos(10.14), ios(7.0), macCatalyst(14.0), tvos(17.0)) API_UNAVAILABLE(visionos);
^
7 errors generated.

/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:22:24: 'AVAuthorizationStatusAuthorized' is unavailable: not available on visionOS

/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:23:15: 'AVCaptureDevice' is unavailable: not available on visionOS

/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:23:31: 'authorizationStatusForMediaType:' is unavailable: not available on visionOS

/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:25:19: 'AVAuthorizationStatusNotDetermined' is unavailable: not available on visionOS

/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:27:24: 'AVAuthorizationStatusAuthorized' is unavailable: not available on visionOS

/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:41:6: 'AVCaptureDevice' is unavailable: not available on visionOS

/Users/ryandawson/Dev/Owlchemy/TestProject/TestProjectVisionOS/Builds/VisionOS/TestProject/Classes/Unity/AVCapture.mm:41:22: 'requestAccessForMediaType:completionHandler:' is unavailable: not available on visionOS

Is this a known issue? Will microphone support not be available for Apple Vision Pro?

Click on the error and add && !PLATFORM_VISIONOS

Yeah this is a known issue. Microphone support should be available in the future but not something we’ve enabled through the normal unity path yet.

1 Like

Is there an ETA on microphone access or a potential work around for the time being? Would love to get access to that for a project we’re working on