xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

报错如下:

1
2
xcodebuild
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

报这个错误的原因是 xcode-select 不在默认的路径

  1. 找到 xcode-select 的当前路径终端命令行

    1
    2
    xcode-select --print-path
    /Library/Developer/CommandLineTools
  2. 设置 xcode-select 到指定位置

    1
    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
  3. 验证是否设置成功

    1
    2
    xcode-select --print-path
    /Applications/Xcode.app/Contents/Developer

本文参考:https://www.cnblogs.com/qqcc1388/p/11021870.html