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
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.