Failure of AudioUnitSetProperty when using MacCatalyst (works on macOS)

I was trying to set custom audio output device for a generated audio on macCatalyst.

While using let status = AudioUnitSetProperty(outputUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &outputDeviceID, UInt32(MemoryLayout.size))

kAudioOutputUnitProperty_CurrentDevice is invalid, and status = -10879, indicating an error.

STEPS TO REPRODUCE

  1. Set Run Destination to MacOS and run the program. "AudioUnitSetProperty: 0" should be printed, indicating it works fine.
  2. Set Run Destination to Mac Catalyst and run the program. "Error setting output device: -10879" should be printed, indicating an error.

Hello @ha0ch3n, thank you for your post. Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. I'd greatly appreciate it if you could open a bug report, include a sysdiagnose, and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

Sure! I just opened a bug report FB16034376.

Thank you for your response to the bug report. We’ve uploaded a follow-up project code and system diagnosis to FB16034376 for further review.

We developed a macOS bundle to enable a macCatalyst app to call macOS APIs. While most macOS API calls function correctly, including a successful reference case using NSAlert() from AppKit, the call to AudioUnitSetProperty fails.

STEPS TO REPRODUCE

  • Set the Run Destination to macCatalyst.
  • Run the program.

EXPECTED OUTPUT

  • Clicking the "AppKit Alert (WORKS)" button successfully invokes a macOS API (NSAlert).
  • Clicking the "Set Audio Device (FAILS)" button successfully sets the audio output device via AudioUnitSetProperty.

ACTUAL OUTPUT

  • Clicking the "AppKit Alert (WORKS)" button works as expected.
  • Clicking the "Set Audio Device (FAILS)" button results in an error message: "Error setting output device: -10879", indicating a failure in calling the macOS API.

ADDITIONAL NOTES

  • System diagnosis was run on Feb 5th, 2025, 18:56pm. We first clicked "AppKit Alert (WORKS), then clicked Set Audio Device (FAILS).
  • Xcode Version 16.0 (16A242d)

Our company is looking to develop a UI that supports both macOS and iOS while maximizing code reuse. Could you advise on the best approach to achieve this moving forward?

We appreciate your guidance.

Failure of AudioUnitSetProperty when using MacCatalyst (works on macOS)
 
 
Q