為什麼 macOS 下的工具鏈如此依賴 Xcode?

有什麼不安裝 Xcode 就使用工具鏈的方法嗎?


其實brew依賴的不是Xcode,是Command Line Tools,這兩者的關係其實不大,你可以在不安裝Xcode的情況下安裝Command Line Tools,而安裝Xcode的情況下默認是不安裝Command Line Tools的。

所以你這個問題就有點類似於問:為什麼Linux下的工具鏈如此依賴Intellij IDEA for linux……

沒了,直接裝Command Line Tools(類似於gcc)就可以了


本質是這樣:

Xcode 依賴 Command Line Tools,安裝 Xcode 的時候會彈出 Command Line Tools 的安裝請求從而解決這個依賴。

其實也是有的,Download More (需要開發者賬號) 這裡能下載到 。

當然 Command Line Tools 是集成的是 Clang,gcc 只有 homebrew。系統默認的 gcc 其實也是 Clang。

(以及 Linux 的 Tool Chain 並不依賴 IDEA 那套。


有啊,獨立安裝 Command Line Tools 就行,上面有回答已經提到了,在 Apple 的開發者下載頁里可以找到。比如 Command Line Tools (macOS 10.12) for Xcode 9.dmg ,你沒有開發者帳號的話就找別人幫忙下一個。

附上這個 dmg 的描述:

This package enables UNIX-style development via Terminal by installing command line developer tools, as well as macOS SDK frameworks and headers. Many useful tools are included, such as the Apple LLVM compiler, linker, and Make. If you use Xcode, these tools are also embedded within the Xcode IDE.


xcode-select --install

上述命令並不會安裝 XCode 那個IDE,只裝命令行的工具


有,在一個新系統上直接運行 gcc,會提示下載 Command Line Tools。不用註冊什麼賬號,也不用 Xcode 就能下載安裝。


沒有。任何系統都有自己的「native」編譯器,只不過恰巧Linux用的是gcc罷了。windows則是msvc,MacOS就是llvm clang.你如果想換一款編譯器首先都有系統的runtime也就是libc,還是得從Xcode獲取。去下載一個吧,速度不慢也不要錢。


推薦閱讀:

如何學習好 Keynote?
熱愛 OS X / macOS 的人更多是左派嗎?熱愛 Windows 的人更多是右派嗎?
macbook safari無法上網?
為什麼 OS X 都默認安裝 GarageBand ?
Mac OS X 10.11 sudo 指令出問題了么?

TAG:macOS | Xcode | GCC | Clang |