Issues with macOS Microphone Permissions Not Prompting After Code Signing with Hardened Runtime

Hello everyone,

I'm developing a macOS app with Python and PyInstaller, and I've hit a roadblock with microphone permissions. The app prompts for microphone access correctly when running unsigned. However, after signing with the hardened runtime option, the prompt no longer appears, and the app can't access the mic.

Here's what my setup looks like:

  • Python app packaged with PyInstaller
  • Entitlements file with com.apple.security.device.microphone and com.apple.security.cs.allow-unsigned-executable-memory
  • Signing command:
    codesign --deep --force --verify --timestamp --verbose --sign "Developer ID Application: [******]" --options=runtime --entitlements ./entitlements.plist main.app
    
  • I've tried resetting microphone permissions and PRAM to no avail.
    1. entitlements.plist looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <!-- 允许应用使用未签名的可执行内存 -->
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <!-- 其他你的应用可能需要的键 -->
    <!-- 比如麦克风使用权限 -->
    <key>com.apple.security.device.microphone</key>
    <true/>
</dict>
</plist>

Testing without the --options=runtime flag works perfectly - the mic prompt appears, and the log file is created. With the flag, neither the prompt nor the log file appears.

Has anyone faced a similar issue or can offer insight into why the hardened runtime option might be causing this? Any guidance or workaround to have the microphone permission prompt appear with hardened runtime enabled would be highly appreciated.

Thanks in advance for your help!

Given that your entitlements property list has comments, I recommend that you normalise it before passing it to codesign. See the callout in the Configure Your Entitlements section of Creating Distribution-Signed Code for Mac.

Next, I recommend that dump the entitlement of your built binary. Your .entitlements file is an input to the code signing process, but sometimes things can get misplaced during that process.

To dump your entitlements, use:

% codesign -d --entitlements - /path/to/your.app

Finally, make sure you set NSMicrophoneUsageDescription in your Info.plist. I don’t think that’s something that’ll induce the behaviour you’re seeing, but it’s good practice regardless.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Issues with macOS Microphone Permissions Not Prompting After Code Signing with Hardened Runtime
 
 
Q