Force xcodebuild use a specific SDK only

compatibilityhomebrewinstallunixxcode

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?

Best Answer

You run xcodebuild like this:

xcodebuild -sdk "/path/to/sdk/" -project myproj.xcodeproj