Header Search Paths in XCode - Is it possible to set a macro or variables so they're relative to the SDK version?

Justin Searls picture Justin Searls · Aug 8, 2009 · Viewed 10k times · Source

Update: It appears that a recent XCode update may have changed this macro, please see this Question & Answer for more information: Obtaining older SDKROOT behavior in XCode


Situation: I'm using libxml2 on an iPhone project and I've added it as relative to the SDK version. However, in order to actually use it in the project, it needs to be added to the Header Search Paths in the Project Settings.

I would like this to be entirely SDK version agnostic, so the header search path should also be relative to SDK version, however there's no apparent way to do expand a variable representing the SDK folder.

For example, here's the actual literal path:

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/libxml2

I'd like to be able to express

$MAGICAL_BASE_SDK_VARIABLE/usr/include/libxml2

Is this something that can be accomplished using XCode?

Answer

Justin Searls picture Justin Searls · Aug 8, 2009

Figures that I'd figure this out an hour after fighting it and only 3 minutes after posting it.

The macro to use in this situation is ${SDKROOT}. Therefore, all one needs to do is add a Header Search Path like: "${SDKROOT}/usr/include/libxml2", and it will resolve appropriately.

Note the code isn't totally working yet, but it's clear that it's at least picking up the location of the header files.