XCode:找不到文件?

发布于 2024-08-09 08:35:15 字数 257 浏览 1 评论 0原文

我有一个使用静态库(.a 文件)中的类的目标。

我在 XCode 中有静态库,它是目标所必需的,并且位于“链接库”部分中。

在代码中,我使用静态库中的类,例如:

#include "class_from_static.h"

但是 XCode 抱怨找不到文件“class_from_static.h”。不是应该找得到吗?

我已经验证静态库确实包含这个类。

有什么问题吗?

I have a target that uses classes from a static library (.a file).

I have the static library in XCode and it is required for the target and is in the "Linked Libraries" section.

In the code I use a class from the static library like:

#include "class_from_static.h"

But XCode complains that the file "class_from_static.h" is not found. Shouldn't it find it?

I have verified that the static library does indeed contain this class.

What is the issue?

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

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

发布评论

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

评论(3

沉默的熊 2024-08-16 08:35:15

静态库不像框架;它不像框架。它们只包含代码,不包含标题。您需要将包含 class_from_static.h 的文件夹添加到您的用户头搜索路径中,或者直接将头文件添加到项目中。如果双击该设置,您可以将文件夹拖放到列表中。

Static libraries aren't like frameworks; they only contain code, not headers. You need to add the folder containing class_from_static.h to your user header search paths, or just add the header file directly to the project. If you double-click the setting you can drag and drop a folder into the list.

听你说爱我 2024-08-16 08:35:15

除了告诉链接器在哪里可以找到静态库之外,您还必须告诉编译器在哪里可以找到头文件。将头文件添加到项目中也会将它们添加到编译器的搜索路径中。

As well as telling the linker where to find the static library, you must tell the compiler where to find the header files. Adding the header files to the project also adds them to the compiler's search path.

风轻花落早 2024-08-16 08:35:15

也可以尝试使用父文件夹。例如,假设 class_from_static.h 位于名为 Static 的目录中(这也应该是静态库的名称),您可以尝试:

#include <Static/class_from_static.h>

另外,请记住添加,到项目的“构建设置”下的“标头搜索路径”,包含上面的 Static 目录(也可能称为 Static< /代码>)。例如,Vendor/Static,其中包含另一个名为 Static 的目录:

ProjectDir
|- Vendor
   `- Static
      `- Static
        `- class_from_static.h

SSToolkit 是结构化的。

Try it also with the parent folder. For example, assuming class_from_static.h is in the directory named Static (which should also be the name of the static library), you might try:

#include <Static/class_from_static.h>

Also, remember to add, to your project's "Header Search Paths" under "Build Settings," the path to the directory (relative to your project root) that contains the Static directory above (which might also be called Static). E.g., Vendor/Static, which would contain another directory called Static:

ProjectDir
|- Vendor
   `- Static
      `- Static
        `- class_from_static.h

This is how SSToolkit is structured.

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