My Xcode project builds to variations of the same product using two targets. The difference between the two is only on which version of an included library is used. For the .c source files it's easy to assign the correct version to the correct target using the target check box. However, including the header file always includes the same one. This is correct for one target, but wrong for the other one.
Is there a way to control which header file is included by each target?
Here is my project file hierarchy (which is replicated in Xcode):
MyProject
TheirOldLib
theirLib.h
theirLib.cpp
TheirNewLib
theirLib.h
theirLib.cpp
myCode.cpp
and myCode.cpp does thing such as:
#include "theirLib.h"
…
somecode()
{
#if OLDVERSION
theirOldLibCall(…);
#else
theirNewLibCall(…);
#endif
}
And of course, I define OLDVERSION
for one target and not for the other.
Note the #include
must be as shown. Both of the following fail with a file not found error:
#include "TheirOldLib/theirLib.h"
#include "TheirNewLib/theirLib.h"
So is there a way to tell Xcode which theirLib.h
to include per target?
Constraints:
- the two header files have the same name. As a last resort, I could rename one of them, but I'd rather avoid that as this will lead to major hair pulling on the other platforms.
- having to change the #include
to add a reference to the enclosing folder is also something I'd rather avoid, because I would need to do it twice with a conditional compile directive.
- I'm free to tweak my project as I otherwise see fit
Thanks for any help.