2

In Xcode, suppose that there is a framework named Foo. Inside the Foo.framework/Headers folder there are files File1.h and File2.h. The header file File1.h includes File2.h via the following directive:

#include <File2.h>

The Foo framework is a re-package of a C++ library not specifically targeted for the Mac.

Now suppose I have a project that links to the Foo framework. It has a file MyFile.mm that includes File1.h via the following directive:

#import <Foo/File1.h>

Now when I tried to compile MyFile.mm, it always fails because it can't find File2.h. How can I get this to compile and run without modifying the header files of the Foo framework?

For the curious, the actual framework in question is a framework-packaged version of Taglib taken from the Max source tree. The file that I tried to include was <taglib/mp4.tag> and compiling the .mm file that includes it always fail due to mp4tag.h is including <tag.h> without the <taglib/...> prefix in the include directive. The error is not only in this one header files, but there are similar issues in a large number of header files and thus modifying all of these include statements is non trivial. All of the required "missing" header files are actually present in the framework's Header subdirectory.

I'm trying to use Taglib in my app and although I was able to compile Taglib as a framework with header files and add it to my app, I can't seem to get the app to compile due to the issues above.

Anybody has any pointers?

Thanks.

2
  • It sounds to me like there is a bug with the framework - it should be using the same prefixes for its #import statements that it expects users of the framework to use. Commented Jun 26, 2010 at 16:24
  • This framework is not Mac OS X specific and they are C/C++ sources (no Objective-C source code in the framework). Commented Jun 27, 2010 at 16:59

2 Answers 2

1

I think that File1.h should say:

#include "File2.h"

Try checking the "Always Search User Paths" option in Xcode.

Sign up to request clarification or add additional context in comments.

4 Comments

The "Always Search User Paths" is checked (this is the default option). File1.h is part of the open source library and its not just one file (i.e. there are many header files that includes other header files in the library the same way).
OK, at this point I'm sure that the framework is set up incorrectly. If you can't fix it, then you'll need to add a header search path to the Headers folder of the framework.
How can I tell whether the framework is set up correctly or not?
I meant that if it's including its own headers as if they were system headers (in angle brackets), that's incorrect.
0

Here are the steps to fix it:

  1. Change the code to in File1.h to use '#include '.
  2. In the framework project/default target/build phases, set the "copy files" phase and add both File1.h and File2.h.
  3. Make sure that the "copy files" phase is before "compile" phase.

This should fix the issue, as the framework will refer to the files exactly the same way as the code that uses the framework.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.