Why are static library headers not found?

10,037

Solution 1

Despite some helpful advice, I never figured this one out, but here's a little info for anyone in a similar situation. I created the library and dependent project by splitting an original project into two. At first, the library and application were just two targets within the same project. Later, I moved the app to a separate project. Everything seemed to work, and I pushed both projects to remote git repositories. When these were cloned on other computers, however, the library headers were not found.

Later, I discover that the same error occurred when I cloned the projects on the original computer. After a lot of struggle, I pinned it down to one scary detail: the name of the dependent project's folder! (That is, the project with the application, not the library.) Not the name of the .xcodeproject package, not the application identifier, but the name of the containing folder. As soon as I change that, everything works. If I change it back to the original name (on any computer), again the headers are not found.

If anyone has any insight on this, please post an answer!

EDIT: Since I posted this, the same problem occured with another project, and again, merely renaming the folder that contains the .xcodeproject folder fixed the problem.

Solution 2

I don't think it is Git, I think it's xcode. I got a very similar problem here, where xcode / xcodebuild resolves an include path falsely (making it a simple .) With the exactly the same library project and xcconfig files (clean checkout from svn repo) but another containing folder - it works. So, thanx for the solution and don't blame Git anymore ;-)

Share:
10,037
Felixyz
Author by

Felixyz

Fat Agnus hacker grown up to become logic programming advocate and domain modeling aficionado. I host The Search Space podcast (http://thesearch.space/)

Updated on June 04, 2022

Comments

  • Felixyz
    Felixyz almost 2 years

    I've used Clint Harris' tutorial to set up code sharing between projects, and everything works just as expected on my computer. But on my co-worker's machine, it seems the compiler doesn't find the header file from the static library project when he builds.

    My co-worker got my project by cloning a git repository. We've gone through all relevant build flags and XCode settings n times, but the project simply refuses to compile on his machine.

    This is what I asked my co-worker to do, mostly copied and pasted from the tutorial:

    1. Make sure there is NO blank space in the complete path to the projects' directory.
    2. Inside the projects directory, create another folder called "build_output".
    3. In XCode, under “XCode > Preferences" choose the "Building” tab and set “Place Build Projects in” to “Customized location” and specify the path to the common build directory you created.
    4. Set “Place Intermediate Build Files in” to “With build products.”
    5. Choose the “Source Trees” tab and create a new Source Tree variable by clicking on the “+” button and filling in the columns. In both "Setting Name" and "Display Name", put [the name of the shared project which created the static library]. In path, you put the full path to the framework folder.

    Following these steps, the project that uses the static library should compile the same on his machine as on mine. But it doesn't. Basically, the error he gets is:

    error: TheFrameworkHeader.h: No such file or directory
    

    and then a string of other errors caused by the missing header.

    Any strategies for trouble-shooting this? Or anyone who had a similar experience and could share some hard-earned knowledge? Is anything missing from the instructions I've summarized? Do I need to set the roles of headers in the Copy Headers build phase when compiling a static library?

  • Felixyz
    Felixyz almost 15 years
    Thanks, but I've used the build panel on the target in Xcode to set the "User Header Search Paths" correctly (using the name set up in the Source Trees settings in Xcode's preferences), and that's all I did to get it to work on my dev box. (I also set "Other Linker Flags" to -ObjC.) I've now tried this on a third computer, and the only one on which it works is the original dev box.
  • Felixyz
    Felixyz almost 15 years
    Many thanks, but I had already checked this and every other conceivable setting a dozen times. I still don't know what was wrong, but will edit the question to share a little info.
  • Felixyz
    Felixyz almost 15 years
    Added a new answer instead, so the question will not be marked as unanswered.
  • John Biesnecker
    John Biesnecker over 14 years
    I just had the same thing happen. 'ChineseZodiac' == bad. 'Zodiac' == good. WTF?
  • Felixyz
    Felixyz over 14 years
    That makes three of us. Maybe time to file a bug.
  • Felixyz
    Felixyz about 14 years
    No, git is not one of the suspects anymore :) It's still unclear what causes xcode the confusion. Must be some kind of meta-info in the project file?
  • funkybro
    funkybro almost 9 years
    Wow, incredible. This happens periodically on my projects for no apparent reason. Renaming the folder fixes it.