Xcode其本身路徑不對導致的錯誤

問題例如:error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist, use xcode-select to change

個人是因爲裝Alcatraz的時候失敗了,提示error如下:
Xcode Command Line Tools are not currently installed, and are required to run Alcatraz.

後來想起的我的 xcode7.2 是從朋友那邊拷過來的,或許是因xcode本身的路徑不對導致的問題。

下面介紹如何使用終端改xcode的路徑:

1、打開終端
//確認當前工作位置
appledeMacBook-Pro-3:~ 09$ pwd
/Users/apple

//由於忘記具體執行代碼 輸入 xcode-select獲取提示
appledeMacBook-Pro-3:~ 09$ xcode-select

----------
xcode-select: error: no command option given
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
  --install                   open a dialog for installation of the command line developer tools
  -v, --version               print the xcode-select version
  -r, --reset                 reset to the default command line tools path
----------

//發現-p是獲取 xcode現在路徑;-s是轉移到對應路徑

appledeMacBook-Pro-3:~ 09$ xcode-select -p
/Users/apple/Documents/Xcode 2.app/Contents/Developer
//果然 xcode 不在應用程序中的位置

//ls 相應路徑確認存在
appledeMacBook-Pro-3:~ 09$ ls /Applications/Xcode.app/Contents/Developer/
Applications    Library     Platforms   Tools
Documentation   Makefiles   Toolchains  usr

//-s 相應路徑 將 xcode 轉移到對應路徑
appledeMacBook-Pro-3:~ 09$ xcode-select -s /Applications/Xcode.app/Contents/Developer/

//這裏給我報了個錯誤
----------
xcode-select: error: --switch must be run as root (e.g. sudo xcode-select --switch <xcode_folder_path>).
----------
//然後我複製它給我的命令 將路徑寫入

appledeMacBook-Pro-3:~ 09$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
//提示輸入本機密碼
//輸入後成功。
發佈了53 篇原創文章 · 獲贊 4 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章