框架头在 Xcode 中找不到自己的头文件?

发布于 2024-09-07 07:37:33 字数 1199 浏览 2 评论 0原文

在 Xcode 中,假设有一个名为 Foo 的框架。在 Foo.framework/Headers 文件夹内有文件 File1.hFile2.h。头文件 File1.h 通过以下指令包含 File2.h

#include <File2.h>

Foo 框架是 C++ 库的重新封装,并非专门针对针对Mac。

现在假设我有一个链接到 Foo 框架的项目。它有一个文件 MyFile.mm,其中通过以下指令包含 File1.h

#import <Foo/File1.h>

现在,当我尝试编译 MyFile.mm 时,它总是失败,因为找不到 File2.h。如何在不修改 Foo 框架的头文件的情况下编译并运行它?

出于好奇,所讨论的实际框架是 Taglib 的框架打包版本取自 Max 源树。我尝试包含的文件是 并且编译包含它的 .mm 文件总是因 mp4tag.h< /code> 包含 ,但在 include 指令中不包含 前缀。该错误不仅出现在这一个头文件中,而且大量头文件中也存在类似问题,因此修改所有这些包含语句并非易事。所有必需的“缺失”头文件实际上都存在于框架的 Header 子目录中。

我正在尝试在我的应用程序中使用 Taglib,尽管我能够将 Taglib 编译为带有头文件的框架并将其添加到我的应用程序中,但由于上述问题,我似乎无法编译应用程序。

有人有任何指点吗?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

带上头具痛哭 2024-09-14 07:37:33

我认为 File1.h 应该说:

#include "File2.h"

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

I think that File1.h should say:

#include "File2.h"

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

不念旧人 2024-09-14 07:37:33

以下是修复该问题的步骤:

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文