views:

1352

answers:

6

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?

A: 

If you're having trouble building on a particular machine, then the problem likely is a machine or user setting. Such as an environment variable (perhaps INCLUDE_PATH or one of its relatives -- XCode uses GCC). You may have a "." in one of these variables.

The best way to fix this would be to add the needed folder path to the -I switch in the build script.

Max Lybbert
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
A: 

I often forget to check this: are you sure that the missing file (i.e., TheFrameWorkHeader.h" is in the git repository? It may well be that your build settings are correct, but the file somehow did not get added to git correctly.

Max Lybbert
Nope, it's checked into the repository.
Felixyz
A: 

Double check that the "Search Paths->User Header Search Paths" build setting (for all configurations) points to the directory containing the shared Xcode project (you can use the new Source Tree variable you created).

dbarker
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
Added a new answer instead, so the question will not be marked as unanswered.
Felixyz
+3  A: 

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.

Felixyz
I just had the same thing happen. 'ChineseZodiac' == bad. 'Zodiac' == good. WTF?
John Biesnecker
That makes three of us. Maybe time to file a bug.
Felixyz
+1  A: 

Thank you so much for this solution, Sir Lord Mighty. I tried everything but now it works by renaming the project folder...

Martin
Glad to hear it helped someone. I'm not so convinced this has to do with git anymore. Are you using git? I've seen this problem happen with XCode 3.2 as well. Perhaps I should file a bug with Apple.
Felixyz
+2  A: 

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 ;-)

mvd
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?
Felixyz