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.

4

2 回答 2

1

我认为File1.h应该说:

#include "File2.h"

尝试检查 Xcode 中的“始终搜索用户路径”选项。

于 2010-06-26T16:36:09.713 回答
0

以下是修复它的步骤:

  1. 将 File1.h 中的代码更改为使用“#include”。
  2. 在框架项目/默认目标/构建阶段,设置“复制文件”阶段并添加 File1.h 和 File2.h。
  3. 确保“复制文件”阶段在“编译”阶段之前。

这应该可以解决问题,因为框架引用文件的方式与使用框架的代码完全相同。

于 2013-10-10T04:50:11.373 回答