How to get the path of latest SDK available on Mac

前端 未结 3 2008
粉色の甜心
粉色の甜心 2021-02-04 07:05

I know that in order to get xcode install directory from command line I have to use xcode-select -print-path. The result is something like: /Applications/Xcod

3条回答
  •  别跟我提以往
    2021-02-04 07:45

    I'm sure this could be cleaned up a bit, and probably done in a single line of perl, but here's an easy approach:

    sdkparam=`xcodebuild -showsdks | awk '/^$/{p=0};p; /OS X SDKs:/{p=1}' | tail -1 | cut -f3`
    sdkpath=`xcodebuild -version $sdkparam Path`
    

    The point of the awk is to print the "OS X SDKs" block from -showsdks. Then take the last line of it and the 3rd field (it's separated with tabs). Then we ask xcodebuild for the path to that sdk.

提交回复
热议问题