Search code examples
xcode4headerpreprocessorstatic-libraries

Xcode 4 can't locate public header files from static library dependency


Alternate titles to aid search

  • Xcode can't find header
  • Missing .h in Xcode
  • Xcode .h file not found
  • lexical or preprocessor issue file not found

I'm working on an iOS application project which came from Xcode 3. I have now moved to Xcode 4 my project builds a number of static libraries.

Those static libraries also declare public headers and those headers are used by the application code. In Xcode 3.x the headers were copied (as a build phase) to the public headers directory, then in the application project the public headers directory was added to the headers search list.

Under Xcode 4 the build directory is moved to ~/Library/Developer/Xcode/DerivedData/my-project.

The problem is how do I reference this new location in the headers search settings? It seems that:

  • public headers directory is relative to DerivedData directory, but
  • headers search directory is relative to something else (possibly the project location)

How should I set up a static library target for iOS development in Xcode 4 that will ensure the header files are made available to the clients that use the static library when trying to compile as a dependancy?


Solution

  • Xcode 4 Project Fails to compile a static library

    Related question: “lexical or preprocessor issue file not found ” in Xcode 4

    Errors might include; missing header files, "lexical or preprocessor issue"

    Solutions:

    1. Check the "user header paths" are correct
    2. Set "Always search user paths" to YES
    3. Create a group call "Indexing headers" in your project and drag the headers to this group, DO NOT add to any targets when prompted.