Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode 4.5.1. Header Search path not working, <directory/file.h> file not found

I have added a include directory in my home directory. I can run "ls -l ~/include" from the build directory. I have added that directory in both "Header Seach Path" and in "User Header Search Path". In both places I have tried with both non-recursive and recursive. But xcode 4.5.1 can not in any situation find the first stated header file.

It is stated in source code calls.m as:

 #include <directory/file.h>

I get a "Lexical or Preprocessor issue 'directory/file.h' file not found."

But when running xcodebuild from cli it has no problems what so ever to build the source.

I have tried many of the suggestions found on internet

  • Putting a include in /usr/ om my drive
  • Adding a index to the project, adding files with no copy and no "Add to target" marked.
  • Restart xcode.
  • Specifying all specific paths.

But still no go.

What is the problem. Bug´s in xcode?

like image 325
user1775190 Avatar asked Oct 25 '12 18:10

user1775190


2 Answers

I just had a similar issue, and it was because there were spaces in the path which I defined for the Header Search Path. For example, I was defining the following as a search path:

$(SRCROOT)/Frameworks/Headers

which was being expanded out to the following:

/Users/skoota/Documents/Xcode Projects/My App/Frameworks/Headers

as you can see, there are spaces within the path (which are not immediately evident, as you are using the $(SRCROOT) variable) and the compiler doesn't particularly appreciate the spaces. I solved this problem by changing the search path to this:

"$(SRCROOT)"/Frameworks/Headers

(note the quote marks around $(SRCROOT) which escapes the spaces). This now expanded out to:

"/Users/skoota/Documents/Xcode Projects/My App"/Frameworks/Headers

which works perfectly, although looks a bit odd with the embedded " marks. This took me a while to figure out, so hopefully it helps!

like image 178
Skoota Avatar answered Nov 05 '22 10:11

Skoota


This usually happens if there are spaces in your directory's path. To overcome this problem, use double quotes around the path.

Suppose you want to use your project directory, then you should use: $PROJECT_DIR. Enable recursive if you want to search within the folders as well. Alternatively, you can use $(SRCROOT)

like image 5
Kunal Khanna Avatar answered Nov 05 '22 10:11

Kunal Khanna