Last Updated: September 09, 2019
·
1.109K
· mxcl

Compile from CLI with only Xcode installed

NOTE that OS X 10.9 does the below for you transparently, so you don't need the following anymore.

By this I mean, you install Xcode, but don’t install the Command Line Tools package. This means you don’t have to upgrade the Command Line Tools package, etc. So it’s for convenience.

Make this accessible to your shell:

ccenv() {
  SDK="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk"
  export CC='xcrun cc'
  export CPPFLAGS="-isystem$SDK/usr/include -iframework$SDK/System/Library/Frameworks"
  export LDFLAGS="-L$SDK/usr/lib"
}

Then you type ccenv in your shell to enable this. If that does’t work, try a brew sh.

1 Response
Add your response

I'd rather use this as SDK: xcodebuild -version -sdk macosx Path

over 1 year ago ·