What does XCode actually do to enable microphone recording?

In XCode generator of Projucer, there’s an option to enable audio record request, without which would make standalone apps not requesting audio recording at startup and have all-zero input data.

However, I modified JUCE with CMake, so does anyone knows how to do it with out XCode, such as clang command-line options?

Projucer adds an NSMicrophoneUsageDescription entry to the Info.plist:

Did you try using the new juce6 branch? It has CMake support included.
If you don’t want to or can’t use JUCE 6, you can also have a look at FRUT (I’m the author). Even if you stick wirh your custom CMake code, you can read the code of FRUT to see how to reproduce what Projucer does in CMake.

I hope this helps!

I’ve noticed that plist entry and tried copy-paste it in my app’s plist, but it have no effect.

Previously I were thought Xcode have extra operations, but it seems not. So is there any global cache? I tried both reboot my computer and run tccutil reset Microphone, both not help.

And this is the whole content of my info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <string>This app requires audio input. If you do not have an audio interface connected it will use the built-in microphone.</string>

In addition, I read this document and Apple says you should call AVCaptureDevice.authorizationStatus for: and AVCaptureDevice.requestAccess to make it work. I browsed JUCE’s source code and it only make these calls in iOS Camera.

You need to modify the Info.plist template before it gets processed by Xcode. You can’t just modify the Info.plist inside the .app.

I succeeded. Actually it only requires to add the NSMicrophoneUsageDescription stuff in the Info.plist in final app. But Apple has a system-wide cache remembering applications’ paths. So after modifying plist, I have to also move the app bundle folder to somewhere else, then it will ask for the microphone at startup.