【教程】MacOS绕过Apple Develop ID获取麦克风权限

转载请注明出处:小锋学长生活大爆炸[xfxuezhagn.cn]

如果本文帮助到了你,欢迎[点赞、收藏、关注]哦~

以这个电脑音频频谱显示工具为例:https://github.com/1061700625/SpectraTray

使用Swift

不需要Apple Develop ID,推荐!

原理是通过swift来做一个启动器。

0、准备干净的环境。

bash 复制代码
python -m venv tray
source tray/bin/activate
pip install -i https://pypi.org/simple pystray pillow numpy SoundCard pyobjc

1、创建原生启动器 App。

bash 复制代码
mkdir -p SpectraTray.app/Contents/{MacOS,Resources}
mkdir -p SpectraTray.app/Contents/Resources/pysrc
cp app.py SpectraTray.app/Contents/Resources/pysrc/
cp -R tray SpectraTray.app/Contents/Resources/tray
cp SpectraTray.ico SpectraTray.app/Contents/Resources/

2、写 Swift 启动器。

bash 复制代码
cat > main.swift <<'SWIFT'
import Foundation
import AVFoundation

func runPython() {
    let bundleURL = Bundle.main.bundleURL
    let py = bundleURL.appendingPathComponent("Contents/Resources/tray/bin/python3").path
    let script = bundleURL.appendingPathComponent("Contents/Resources/pysrc/app.py").path

    let task = Process()
    task.executableURL = URL(fileURLWithPath: py)
    task.arguments = [script]

    // 完全后台(不弹终端)
    task.standardOutput = FileHandle.nullDevice
    task.standardError  = FileHandle.nullDevice

    do { try task.run() } catch { }

    exit(0)
}

// 先触发一次麦克风权限(允许后 python 才能录到 BlackHole)
AVCaptureDevice.requestAccess(for: .audio) { _ in
    runPython()
}

RunLoop.main.run()
SWIFT

swiftc main.swift -o SpectraTray.app/Contents/MacOS/SpectraTray

3、写 Info.plist。

bash 复制代码
cat > SpectraTray.app/Contents/Info.plist <<'PLIST'
<?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>CFBundleName</key><string>SpectraTray</string>
  <key>CFBundleDisplayName</key><string>SpectraTray</string>
  <key>CFBundleIdentifier</key><string>local.spectratray</string>
  <key>CFBundleExecutable</key><string>SpectraTray</string>
  <key>CFBundlePackageType</key><string>APPL</string>
  <key>CFBundleShortVersionString</key><string>0.0.2</string>
  <key>CFBundleVersion</key><string>1</string>
  <key>CFBundleIconFile</key><string>SpectraTray.ico</string>
  <key>LSBackgroundOnly</key><true/>
  <key>NSMicrophoneUsageDescription</key><string>用于捕获系统音频(如 BlackHole)并显示实时频谱</string>
  <key>LSApplicationCategoryType</key><string>public.app-category.utilities</string>
</dict>
</plist>
PLIST

4、去掉 quarantine。

bash 复制代码
xattr -dr com.apple.quarantine SpectraTray.app

5、刷新图标。

bash 复制代码
touch SpectraTray.app

6、启动 SpectraTray.app

相关推荐
皮卡车厘子1 天前
Mac 挂载目录
macos
良逍Ai出海1 天前
在 Windows & macOS 上安装 Claude Code,并使用第三方 Key 的完整教程
windows·macos
热爱生活的五柒1 天前
linux/mac/wsl如何使用claude code,并配置免费的硅基流动API?(官方的需要付费订阅)
linux·运维·macos
胖胖大王叫我来巡山1 天前
mac本地安装DataEase桌面版
macos
奋斗者1号1 天前
OpenClaw 部署方式对比:云端、WSL、Mac 本机、Ubuntu 虚拟机(2026年2月最新主流实践)
linux·ubuntu·macos
玉梅小洋1 天前
Android SDK 安装指南(MacOS 和 Windows)
android·windows·macos·sdk
2501_916007471 天前
没有 Mac 用户如何上架 App Store,IPA生成、证书与描述文件管理、跨平台上传
android·macos·ios·小程序·uni-app·iphone·webview
胖胖大王叫我来巡山1 天前
Mac通过源码安装部署SQLBOT
macos
June bug2 天前
【领域知识】广告全链路测试
macos·objective-c·cocoa
fendoudexiaoniao_ios2 天前
iOS 列表拖拽cell排序
ios·swift