How to get the path of latest SDK available on Mac

前端 未结 3 2017
粉色の甜心
粉色の甜心 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:37

    The easiest way I found so far is:

    xcrun --show-sdk-path
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-04 07:56

    To be more precise,

    xcrun --sdk macosx --show-sdk-path
    
    0 讨论(0)
提交回复
热议问题