直接通过终端指令开启macos隐藏开发者功能:safari需执行defaults write com.apple.safari命令启用webgpu等实验性功能;mac app store需写入webkitdeveloperextras和includedebugmenu;系统设置需注册enabledpreferencepanels数组并重启systemsettings;系统级开发者模式则用sudo defaults write developermode并重启。
直接通过终端指令开启 macos 各项隐藏开发者功能,关键在于向对应应用或系统组件的 defaults 域写入特定布尔值。这些操作不修改系统文件,仅影响当前用户的偏好设置,全部可逆、安全可靠。
开启 Safari 的完整开发与实验性功能
仅勾选「显示开发菜单」还不够——要解锁 WebGPU、容器查询、远程自动化等深层能力,需终端配合:
- 先退出 Safari(确保无残留进程)
- 执行以下命令逐项启用(每条单独运行,重启 Safari 后生效):
defaults write com.apple.Safari WebKitWebGPUEnabled -bool true
defaults write com.apple.Safari CSSContainerQueriesEnabled -bool true
defaults write com.apple.Safari AccessibilityObjectModelEnabled -bool true
defaults write com.apple.Safari IncludeDevelopMenu -bool true(补全开发菜单底层支持) - 如需 WebDriver 自动化支持,额外运行:
defaults write com.apple.Safari AllowRemoteAutomation -bool true
激活 Mac App Store 的 Debug 菜单
用于排查下载卡顿、刷新商店缓存、重置队列等运维级操作:
- 完全退出 Mac App Store(检查 Activity Monitor 中无
appstore或storeagent进程) - 在终端中一次性输入两行命令:
defaults write com.apple.appstore WebKitDeveloperExtras -bool true
defaults write com.apple.appstore IncludeDebugMenu -bool true - 重新打开 Mac App Store,顶部即出现「Debug」菜单
解锁系统设置中的隐藏面板
让「开发者」、「诊断与用量」等未默认展示的系统偏好设置面板直接出现在设置里:
- 运行命令注册模块 ID:
defaults write com.apple.systempreferences EnabledPreferencePanels -array "com.apple.preference.developer" "com.apple.preference.diagnostics" - 重启系统设置应用:
macOS Ventura 及更新版:执行 killall SystemSettings
Monterey 及更早版本:执行 killall System Preferences - 重新打开「系统设置」,搜索“开发者”即可直达
启用系统级开发者模式(非 GUI 可见时)
当「隐私与安全性」中未显示开发者模式开关(如旧系统或配置异常),可用终端强制激活:
- 运行:
sudo defaults write /var/db/com.apple.xpc.launchd/config/DeveloperMode -bool true - 输入管理员密码(输入过程不显示字符,属正常)
- 立即重启:
sudo shutdown -r now - 重启后,USB 设备识别、自签名工具执行、Xcode 调试接口等均可用











