开发者

XCode: File Not Found?

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:

#includ开发者_如何学编程e "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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜