[英]A framework header cannot find its own header files in Xcode?
In Xcode, suppose that there is a framework named Foo
. 在Xcode中,假设有一个名为
Foo
的框架。 Inside the Foo.framework/Headers
folder there are files File1.h
and File2.h
. 在
Foo.framework/Headers
文件夹中,有File1.h
和File2.h
文件。 The header file File1.h
includes File2.h
via the following directive: 头文件
File1.h
通过以下指令包括File2.h
:
#include <File2.h>
The Foo
framework is a re-package of a C++ library not specifically targeted for the Mac. Foo
框架是对C ++库的重新打包,该库并非专门针对Mac。
Now suppose I have a project that links to the Foo
framework. 现在假设我有一个链接到
Foo
框架的项目。 It has a file MyFile.mm
that includes File1.h
via the following directive: 它具有通过以下指令包含
File1.h
的文件MyFile.mm
:
#import <Foo/File1.h>
Now when I tried to compile MyFile.mm
, it always fails because it can't find File2.h
. 现在,当我尝试编译
MyFile.mm
,它总是失败,因为找不到File2.h
。 How can I get this to compile and run without modifying the header files of the Foo
framework? 我如何在不修改
Foo
框架的头文件的情况下进行编译和运行?
For the curious, the actual framework in question is a framework-packaged version of Taglib taken from the Max source tree. 出于好奇,实际的框架是从Max源代码树中获取的Taglib框架包装版本。 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. 我尝试包含的文件是
<taglib/mp4.tag>
并且由于mp4tag.h
而导致编译包含该文件的.mm
文件总是失败,因为mp4tag.h
包含了<tag.h>
而前缀中没有<taglib/...>
包含指令。 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. 该错误不仅存在于此头文件中,而且在大量头文件中也存在类似的问题,因此修改所有这些include语句并非易事。 All of the required "missing" header files are actually present in the framework's
Header
subdirectory. 所有必需的“缺失”头文件实际上都存在于框架的
Header
子目录中。
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. 我试图在我的应用程序中使用Taglib,尽管我能够将Taglib作为带有头文件的框架进行编译并将其添加到我的应用程序中,但由于上述问题,我似乎无法使该应用程序进行编译。
Anybody has any pointers? 有人有指针吗?
Thanks. 谢谢。
I think that File1.h
should say: 我认为
File1.h
应该说:
#include "File2.h"
Try checking the "Always Search User Paths" option in Xcode. 尝试检查Xcode中的“始终搜索用户路径”选项。
Here are the steps to fix it: 以下是修复此问题的步骤:
This should fix the issue, as the framework will refer to the files exactly the same way as the code that uses the framework. 这应该可以解决该问题,因为框架将使用与使用框架的代码完全相同的方式来引用文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.