Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the path to the current MacOSX SDK when only Command Line Tools are installed?

We are trying to locate the current platform SDK used by some of our OSX machines (10.11). On those machines, only the Command Line Tools are installed, not the full blown Xcode app.

Looking up on SO, we were able to find the command xcrun --show-sdk-path, which prints out an empty line.

On the other hand, xcrun --show-sdk-version correctly shows 10.11.

Is there a way to locate the path to the SDK used by our compilation tasks ?

like image 436
Ad N Avatar asked Sep 29 '16 14:09

Ad N


People also ask

Where is MacOSX SDK?

The SDK is located at /Applications/Xcode. app/Contents/Developer/Platforms/MacOSX.

How do I check my Xcode SDK version?

framework file, locate and open the Info. If you are using an IDE (Integrated Development Environment), such as Xcode, look for the value for the key Bundle versions string. Xcode automatically formats the file in a table. If you are not using an IDE, the value to look for is CFBundleShortVersionString.

What are macOS command line tools?

The Command Line Tools Package is a small self-contained package available for download separately from Xcode and that allows you to do command line development in macOS. It consists of the macOS SDK and command-line tools such as Clang, which are installed in the /Library/Developer/CommandLineTools directory.


2 Answers

This is very late, but I've only just started grappling with this.

Running on El Capitan, 10.11.6.

$ xcrun --show-sdk-version
10.11
$ xcrun --sdk macosx10.11 --show-sdk-path
          << blank line here

but

$ xcrun --sdk macosx10.12 --show-sdk-version
10.12
$ xcrun --sdk macosx10.12 --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

Just for completeness,

$ xcrun --sdk macosx10.13 --show-sdk-version
10.11
$ xcrun --sdk macosx10.13 --show-sdk-path
          << blank line here

and

$ ls -l /Library/Developer/CommandLineTools/SDKs/
total 8
drwxr-xr-x  5 root  wheel  170  4 Jun 16:14 MacOSX.sdk
lrwxr-xr-x  1 root  wheel   10  4 Jun 16:13 MacOSX10.12.sdk -> MacOSX.sdk

(isn't that last symlink the wrong way round?)
(no, it’s the way Apple intended, judging by Mojave)

like image 148
Simon Wright Avatar answered Sep 20 '22 03:09

Simon Wright


How about

xcode-select --print-path

The man page says:

Prints the path to the currently selected developer directory. This is useful for inspection, but scripts and other tools should use xcrun(1) to locate tool inside the active developer directory.

On a Mac with only the command line tools installed I get:

/Library/Developer/CommandLineTools

and xcrun --show-sdk-path gives me the same blank line as you get.

like image 27
jwd630 Avatar answered Sep 20 '22 03:09

jwd630