bobobobo
bobobobo

Reputation: 67224

"Proper way" to add a folder to the include path in XCode 4

I know that there is a way to add a "Search Path" in XCode settings for a specific project.

enter image description here

(* I know about this)

But I'm interested to know the "proper" way to permanently add an include folder to XCode.

What I did was add <Eigen> to /usr/include. My code now goes:

#include </usr/include/Eigen/Eigen> // works ok

But it really should look like

#include <Eigen/Eigen> // does NOT work

But XCode does NOT seem to consider /usr/include as part of the build path. Indeed, it gets ALL its header files (including ones like <stdio.h>) from a path like

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include

Wow, what a sweet path.

I'm not sure I want to fiddle with /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include, but at the same time, I don't want to modify my XCode project settings each time I want to simply #include <Eigen/Eigen>.

What is the RECOMMENDED way to add a folder to XCode's INCLUDE path, so that it works for every new project automatically?

Upvotes: 4

Views: 12456

Answers (2)

Andrew Eades
Andrew Eades

Reputation: 125

Here's how to do it:

  • Add $(PROJECT_DIR)/Your/Include/Folder to the User Search Paths
  • Make Always Search User Paths = Yes

Upvotes: 0

sedavidw
sedavidw

Reputation: 11691

Go into the Get Info window (Cmd + I) Select the Build tab Add the directories you'd like to include under "Search Header Paths"

You'd have to do this for every project you would want to include with Eigen but I think that is the recommended way to do things. Just keep it in one place and have all projects that use it reference that location

Upvotes: 3

Related Questions