22

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/Xcode.app/Contents/Developer

Is there any command to get latest SDK folder? I need as result something like: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/

If it's not possible to get the SDK complete path I need at least SDK number and I'll try to build the path.

Mircea Ispas
  • 20,260
  • 32
  • 123
  • 211

3 Answers3

58

The easiest way I found so far is:

xcrun --show-sdk-path
Adrian Petrescu
  • 16,629
  • 6
  • 56
  • 82
Ruslan Ulanov
  • 947
  • 1
  • 10
  • 12
23

To be more precise,

xcrun --sdk macosx --show-sdk-path
Sriram Murali
  • 5,804
  • 2
  • 26
  • 32
11

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.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610