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’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">
<dict>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires audio input. If you do not have an audio interface connected it will use the built-in microphone.</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>TBTSpectrometer</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.threebodytech.spm.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string></string>
<key>CFBundleName</key>
<string>TBTSpectrometer</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.0.1</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
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.
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.