开发者

A framework header cannot find its own header files in Xcode?

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 开发者_StackOverflowto 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.


I think that File1.h should say:

#include "File2.h"

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜