XCode:找不到文件?
我有一个使用静态库(.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
静态库不像框架;它不像框架。它们只包含代码,不包含标题。您需要将包含
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.除了告诉链接器在哪里可以找到静态库之外,您还必须告诉编译器在哪里可以找到头文件。将头文件添加到项目中也会将它们添加到编译器的搜索路径中。
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.
也可以尝试使用父文件夹。例如,假设
class_from_static.h
位于名为Static
的目录中(这也应该是静态库的名称),您可以尝试:另外,请记住添加,到项目的“构建设置”下的“标头搜索路径”,包含上面的
Static
目录(也可能称为Static< /代码>)。例如,
Vendor/Static
,其中包含另一个名为Static
的目录:SSToolkit 是结构化的。
Try it also with the parent folder. For example, assuming
class_from_static.h
is in the directory namedStatic
(which should also be the name of the static library), you might try: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 calledStatic
). E.g.,Vendor/Static
, which would contain another directory calledStatic
:This is how SSToolkit is structured.