5

I'm adding unit tests (SenTest) to my existing XCode 4.2 project. XCode is complaining that it can't find the required Box2D header files. For instance,

  Box2D/Dynamics/b2Fixture.h file not found

The Box2D source files are added to my project under the "libs" group. The header files are found without a problem when building the non-test target. Obviously, I can't add the header files to the test target, but I've added all of Box2D's .cpp files to that target. That just resulted in more of the "Lexical or Preprocessor Issue"s, as above.

How do I tell XCode where to find these header files?

Rohit Vipin Mathews
  • 11,629
  • 15
  • 57
  • 112
user371320
  • 1,388
  • 14
  • 23

1 Answers1

3

I don't believe you need to specify the folder when referencing a .h file. If only the .h file is added to the project in any group or subgroup XCode is able to find the path when you reference the .h file by the name only.

Greg
  • 8,230
  • 5
  • 38
  • 53
  • I'm only using an #import "Box2D.h" statement in my .mm file. Box2d.h, however, pulls in everything with #include statements. I'd rather not fork Box2D to enable the build, and since the non-test target builds without changing the Box2D source, I'm guessing I can convince the test target to build as well. But yes, I'm pretty sure you are right. – user371320 Mar 21 '12 at 10:31
  • Changing the "Box2D.h" code from to "...h" does eliminate the error. I'd just like to have the test target find the header files in the same manner that the main target does. – user371320 Mar 21 '12 at 10:39
  • What's the difference between the main target and the test target? Any specific build settings have been changed? Are they both Debug/Release? As I understand your problem you want to have a project with different set of files depending on the target (e.g. add the unit testing .m and .h files only for a specific target)? – Greg Mar 21 '12 at 16:01
  • 1
    As already noted Box2D is designed to be included like #include so you need to have the folder _above_ that which contains Box2D.h in the headers search path for your project/target. – iforce2d Mar 22 '12 at 10:55
  • 8
    The offending setting was "Always Search User Paths". In my main target, this was set to "Yes", but XCode created the unit test target with a "No" setting. – user371320 Mar 30 '12 at 15:26