I am trying to fix a homebrew formula which uses xcodebuild to build a dependency. Unfortunately, this dependency relies on an older SDK, MacOSX10.12.sdk. I cannot make this project use a newer SDK as it would require vast refactoring to the codebase. Moreover, this library is from Apple and they chose to drop support for it on purpose in the newest Xcode SDK.

Fortunately, I have managed to find the SDK which I need from this repository on Github. Yet now I do not know how to force xcodebuild to use the SDK which I need. No matter what options or variables I set, xcodebuild always uses the default SDK from Xcode.

The version of the system I'm using for this is 10.12.6. Yes, even though the version of the system itself is 10.12, Xcode refuses to use an SDK which matches said version.

So how can I force xcodebuild to use my older SDK in my own custom directory?


You run xcodebuild like this:

xcodebuild -sdk "/path/to/sdk/" -project myproj.xcodeproj
  • I have already tried the -sdk flag. xcodebuild still invokes clang with flags such as -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk and -mmacosx-version-min=10.13. It also invokes libtool with MACOSX_DEPLOYMENT_TARGET=10.13 and -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk – GDP2 Dec 19 '17 at 19:22
  • Are you sure you haven't actually set those paths to the 10.13 SDK in the xcodeproj itself? – jksoegaard Dec 19 '17 at 19:34
  • I am not sure about that. Where can I find those paths in Xcode? – GDP2 Dec 19 '17 at 19:35
  • In the build settings - but I would recommend looking at the Xcode project files with a simple text editor first to confirm. – jksoegaard Dec 19 '17 at 20:01
  • 1
    Thanks for the suggestions. It seems that you are right; the project settings try to always use the latest SDK & try to always deploy to the latest system version. Fortunately, ilovezfs (one of homebrew's maintainers) helped me to solve my problem without having to use an older SDK by setting some environment variables. He explains it here. I had already tried to do what he did, but I guess I screwed it up by trying to use an older SDK. – GDP2 Dec 19 '17 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .