controlling which project header file Xcode will include

Posted by jdmuys on Stack Overflow See other posts from Stack Overflow or by jdmuys
Published on 2010-04-07T23:57:40Z Indexed on 2010/04/08 0:03 UTC
Read the original article Hit count: 385

Filed under:
|
|

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.

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.
- I'm free to tweak my project as I otherwise see fit

Thanks for any help.

© Stack Overflow or respective owner

Related posts about xcode

Related posts about include