首页 文章

更改xcrun开发者路径

提问于
浏览
59

如何更改xcrun指向的目录?目前正指向

xcrun:错误:无法统计活动的Xcode路径'/Volumes/Xcode/Xcode44-DP7.app/Contents/Developer' . (没有相应的文件和目录)

我需要改变位置 . 谢谢 .

9 回答

  • 12
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
    
  • 0

    使用 xcode-select -switch 选择默认使用的Xcode版本 .

  • 5

    在我的情况下,我不得不:

    • 安装Xcode的命令行工具,转到首选项 - >位置并为命令行工具设置正确的值 .

    • 在下载 - >组件选项卡中,我在名为命令行工具的行上单击安装 .

    • Marmalade开始与Xcode合作 .

  • 9
    sudo xcode-select --switch /Library/Developer/CommandLineTools
    
  • 179

    如果您运行此命令:

    $ 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
    
  • 14

    Open xcode and navigate to preferences...

    enter image description here

    Select Location of xcode from command line tools.

    enter image description here
    After that perform command from terminal.

  • 7

    或者,改为覆盖DEVELOPER_DIR环境变量:

    export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
    

    此设置对每个用户帐户都是唯一的 . 如果存在,它将覆盖 xcode-select 选项 .

    可选:您可以通过编辑.bash_profile文件在登录会话之间保持此状态 .

  • 0

    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'"
    
  • 46

    我试图通过终端获得Git Clone .

    我得到以下错误:

    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 . 我将 xcode 的名称保留为7.0,将 xcode 8 保留为8.0 .

    我从应用程序中删除了 xcode for 7.0,并将 xcode 8 重命名为 xcode .
    在Xcode的偏好中它很适合位置 xcode 8 但它不在那里 .

    我使用命令更改了位置:

    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
    

    Git Command工作,我可以从GIT下载项目 .

    您也可以从Xcode首选项中执行此操作 .

    enter image description here

    有效 .

相关问题