14

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?

2 Answers 2

20

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!

5

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)

1
  • 1
    Dont get the downvote it was short and it helped me, thanks Kunal Ive been struggling with this for a while.
    – Arbitur
    Jul 25, 2014 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.