【发布时间】:2012-07-12 17:03:48
【问题描述】:
如何更改 xcrun 指向的目录?当前指向
xcrun:错误:无法统计活动 Xcode 路径 '/Volumes/Xcode/Xcode44-DP7.app/Contents/Developer'。 (没有这样的文件或 目录)
我需要更改位置。 谢谢。
【问题讨论】:
标签: xcode
如何更改 xcrun 指向的目录?当前指向
xcrun:错误:无法统计活动 Xcode 路径 '/Volumes/Xcode/Xcode44-DP7.app/Contents/Developer'。 (没有这样的文件或 目录)
我需要更改位置。 谢谢。
【问题讨论】:
标签: xcode
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
【讨论】:
使用xcode-select -switch 选择默认使用的Xcode 版本。
【讨论】:
xcode-select --switch path/to/Xcode.app。
sudo xcode-select --switch /Library/Developer/CommandLineTools
【讨论】:
就我而言,我必须:
【讨论】:
如果你运行这个命令:
$ xcode-select -p
它将打印到屏幕如下:
/Volumes/Xcode/Xcode44-DP7.app/Contents/Developer(在你的情况下)
要将其更改为默认值,您可以执行以下操作:
$ sudo xcode-select -r
Password:
再次检查:
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
从以下网址获取更多信息:
$ xcode-select
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
【讨论】:
或者,改写 DEVELOPER_DIR 环境变量:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
此设置对每个用户帐户都是唯一的。如果存在,它将覆盖 xcode-select 选项。
可选:您可以通过编辑 .bash_profile 文件在登录会话之间保持此状态。
【讨论】:
您无需安装 xcode 即可使用 xcrun。
只需安装 xcode 命令行工具并切换到它。
安装x代码命令行工具
xcode-select --install
切换到命令行工具
sudo xcode-select --switch /Library/Developer/CommandLineTools
【讨论】:
卸载xcode后?
在控制台中运行
sudo xcode-select --reset
【讨论】:
我试图通过终端获取 Git 克隆。
User-Mac-mini:~ user_name$ cd /Users/yser_name/Documents/Developer/Xcode_Projects/Xcode_Proj/AAG/EJ
user-Mac-mini:EJ 用户名$ git clone https://smaplebitbucket.org/projectname/sample.git
我收到以下错误:
xcrun: error: active developer path ("/Applications/Xcode 8.app/Contents/Developer") does not exist, use `xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools (or see `man xcode-select`)
最初我有两个 xcode 7.3 和 8.0。我为 7.0 保留了 xcode 的名称,为 8.0 保留了 xcode 8 的名称。
我从应用程序中删除了 7.0 的 xcode,并将 xcode 8 重命名为 xcode。
在 Xcode 偏好中,它指向位置 xcode 8,但它不存在。
我使用命令更改了位置:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Git 命令有效,我能够从 GIT 下载项目。
您也可以通过 Xcode 偏好设置。
成功了。
【讨论】:
sudo xcode-select --switch /Library/Developer/CommandLineTools 对我有用。
为了您的信息,我用这个搞砸了我的配置:
sw_vers -productVersion | grep -E '^10\.([89]|10)' >/dev/null && bash -c "[ -d /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain ] && sudo -u $(ls -ld /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain | awk '{print $3}') bash -c 'ln -vs XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX$(sw_vers -productVersion).xctoolchain' || sudo bash -c 'mkdir -vp /Applications/Xcode.app/Contents/Developer/Toolchains/OSX$(sw_vers -productVersion).xctoolchain/usr && for i in bin include lib libexec share; do ln -s /usr/${i} /Applications/Xcode.app/Contents/Developer/Toolchains/OSX$(sw_vers -productVersion).xctoolchain/usr/${i}; done'"
【讨论】: