views:

200

answers:

1

(Posting this question for reference purpose, I'll answer immediately)

How to header search paths to Xcode? Especially using include it this syntax:

include <myheader.h>
  1. Adding path globally to all projects like system headers.
  2. Adding path to only to a specific project.
+1  A: 
  1. Look at "Source Tree" tab in Xcode's preference. A path added here will be a system-level path and available to be included.

  2. Set HEADER_SEARCH_PATHS parameter in build settings on project info. I added here "${PROJECT_PATH}" without recursive. This setting works well for most projects. Care about quotes.

About 2nd method:

Xcode uses GCC(or LLVM which compatible with it). GCC has an option -Idir which adding system header searching paths. And this option is accessible via HEADER_SEARCH_PATHS settings in Xcode.

However, path string added to this setting should not contain any whitespace characters because the option passed as shell command argument itself.

But, many Mac OS X users (including me) put their projects on path including whitespace which should be escaped. You can escape it like /Users/my/work/a\ project\ with\ space if you input it manually. But I've chosen escaping them with quotes to use environment variable like "${PROJECT_DIR}".

Or just use . to indicate current directory. I saw this trick on Webkit's source code, but I cannot sure current directory will be set to project directory when build.

Eonil