首先纤房,解釋一下什么是xcode-select
命令:
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).
用我蹩腳的英語翻譯一下籍茧,大概意思為:
輸出或者改變活躍的開發(fā)者目錄的路徑,這個目錄控制著哪個工具會被用于Xcode命令行工具(Xcode command line tools)(例如xcodebuild)以及BSD開發(fā)命令(例如cc捎稚、make)经瓷。
用help查看一下xcode-select
有哪些命令:
WechatIMG2.png
挨個解釋:
xcode-select -h,--help
:查看幫助文檔冒版。xcode-select -p,--print-path
:輸出活躍的開發(fā)者路徑(說通俗點面哼,就是輸出Xcode是路徑)。xcode-select -s <path>,--switch <path>
:為活躍的開發(fā)者目錄設(shè)置路徑太防。(實際上就是設(shè)置默認使用的Xcode妻顶。這個參數(shù)多用于電腦里安裝了多個Xcode的時候,對Xcode的設(shè)置蜒车。)xcode-select -v,--version
:輸出xcode-select
的版本讳嘱。xcode-select -r,--reset
:恢復默認設(shè)置。用法和參數(shù)都介紹完了酿愧,就來說個坑吧:
image.png
雖然執(zhí)行的命令是
xcodebuild
沥潭,但是卻報了一個xcode-select
的error。仔細看報錯信息嬉挡,不難看出钝鸽,我當前的xcode目錄,被認為是:/Library/Developer/CommandLineTools庞钢。很明顯這是一個錯誤的路徑拔恰,所以咱們要將它修改一下:
image.png
這里需要注意一下,
xcode-select --switch /Applications/Xcode.app/Contents/Developer/
命令是需要在root下執(zhí)行的基括。所以要sudo
颜懊。
填坑完畢!!河爹!