tags:

views:

305

answers:

2

I separated my header files in folders like:

libraryA
  |-libA1.h
  |-libA2.h

libraryB
  |-libB1.h
  |-libB2.h

Xcode however removes the path by default, so

#include "libraryA/libA1.h"
#include "libraryB/libB1.h"

doesn't work, only:

#include "libA1.h"
#include "libB1.h"

How can I make xcode preserve the path names for includes?

A: 

The groups in Xcode's file list don't necessarily correspond to folders on disk. If you really want them to work that way, you need to create folders in your source tree, move your headers there, then get info on your file groups in Xcode and point them at the new folders.

Kevin Ballard
I have the .h files in separate folders, not only separate groups.
lajos
+2  A: 

In the build pane for the target, set Header Search Paths to $(SRCROOT) (assuming these are at the top level), or $(SRCROOT)/include, or whatever matches. I only suggest using the build pane here for simplicity sake. I actually recommend that people abandon the build pane and use xcconfig files, in which case, the setting is HEADER_SEARCH_PATHS.

Rob Napier
@Rob: so basically, if HEADER_SEARCH_PATHS is not set, all the paths are removed, but if it has any value, then the paths are preserved?
lajos
No. The default is to look for files directly added to your project. Then it looks in HEADER_SEARCH_PATHS. If HEADER_SEARCH_PATHS is $(SRCROOT), which might expand to /Users/rob/MyCoolProject, then it will look for libraryA/libA1.h in /Users/rob/MyCoolProject/libraryA/libA1.h after looking directly in added files to the project. (But no file in the project will have the name "libraryA/libA1.h". The name of the file is "libA1.h".)
Rob Napier