用 xcode-select 切换开发者工具链
xcode-select 决定由哪个 Xcode 或独立的命令行工具提供 clang、git 和 SDK。
运行 `xcode-select -p` 查看当前开发者目录;用 `sudo xcode-select -s /Applications/Xcode.app` 切换。
01命令
命令
$ xcode-select -p02作用说明
xcode-select 管理一个符号链接(/Library/Developer/CommandLineTools 或某个 Xcode.app),所有开发工具都以它为准。-p 显示当前目标,-s 切换(需要 sudo),-r 恢复系统默认。Xcode 版本更换后出现 unable to find utility 或 SDK 不匹配,多半就是这个设置的问题。xcrun 遵循同一设置,所以切换一次所有工具同时生效。
03风险
!注意: 切换后请运行 `xcodebuild -version` 或 `clang --version` 确认工具链符合预期。
04撤销
撤销
$ sudo xcode-select -r05来源
- xcode-select — manage the active developer directory (macOS)依据: Documents -p to print the active path, -s to switch it, and -r to reset to the default toolchain.
最后验证: 2026-09-17 · 分类: 开发者