Command Line Tool doesn't trigger permission prompt for audio recording

Hello,

I'm developing a Command Line Tool in XCode, in order to capture system audio and save it to a file, which will then be used by a separate process.

Everything works perfectly when running it from either XCode or the native terminal application (see image below), but as soon as I try to run it from any 3rd party application, it doesn't ask for permissions to record sound, and the resultant file ends up soundless.

When archiving it and then running it from other 3rd party applications, e.g Warp (terminal) or spawning it as a child process from a bundled Electron application, it doesn't ask for permissions.

Things of note:

As my use-case involves spawning the executable from Electron as a child process, I've tried to include the appropriate permissions to the parent application too, without success.

I'm really at a loss here, it feels like I've tried everything. Any pointers are much appreciated!

Thanks

I'm in the same boat. The next best thing may be to create an aggregate device and use that instead in the parent application. I really wanted to avoid the user needing to manage their audio settings or use any loopback software. There are others who seem to have figured out the "correct" way but I haven't been able to find any open-source examples https://www.reddit.com/r/electronjs/comments/1d9bjh9/recording_system_audio_on_macos/

I found here that permissions are indeed handled differently based on where/how applications are run: https://developer.apple.com/forums/thread/756510?answerId=789958022#789958022

I was able to get by electron app running as expected during development using this approach:

  • Run the electron app from the terminal, rather than the IDE. This triggers permissions correctly for me.
  • It may be helpful to request more access than is needed (audio + screen) using desktopCapturer.getSources, and then remove it after debugging.
  • The use-case here reserves stdout for audio data, so debugging there is challenging. Instead use this command to view debug logs in a separate terminal: log stream --predicate 'subsystem == "com.example.AudioCap"' --info

For distribution, the issue is back again, at least when using electron-forge to create a .app bundle. I'm not sure if the problem is the electron bundle also needs to declare permissions

Command Line Tool doesn't trigger permission prompt for audio recording
 
 
Q