简体   繁体   English

iOS-在另一个Xcode项目中包含静态库项目…标头问题

[英]iOS - including static library project in another Xcode project… header issues

So here's the scoop: 所以这是独家新闻:

I have an xcode project that builds a standard library. 我有一个构建标准库的xcode项目。 This standard library produces a ".a" file, along with a few header files that need to be visible to whatever client is using said lib. 这个标准库产生一个“ .a”文件,以及一些头文件,对于使用该库的任何客户端,该头文件都必须是可见的。

The standard lib builds to a set directory: 标准库构建到一个设置目录:

/builds/foo/bar/build/

Which looks like this after I build the library: 构建库后,如下所示:

/builds/foo/bar/build/
    lib.a
    headers/
        head1.h
        head2.h
        head3.h

I have a client application that needs to consume this library. 我有一个需要使用此库的客户端应用程序。 It's required that I rebuild the standard lib with every build of the client app, so I set it up as follows: 要求我在每次构建客户端应用程序时都重新构建标准库,因此我将其设置如下:

I created a client application, added the standard lib .xcodeproj file to it, and hooked it up as a direct dependency. 我创建了一个客户端应用程序,向其中添加了标准的lib .xcodeproj文件,并将其连接为直接依赖项。 I linked it appropriately in the "Link Binary with Library" section. 我在“将二进制文件与库链接”部分中进行了适当的链接。 Then, following standard suit, I set it up the client app to search for the header files at the following location: 然后,按照标准设置,将其设置为客户端应用程序,以在以下位置搜索头文件:

/builds/foo/bar/build/headers/

And this works... sort of. 这行得通... If I delete the directory listed above and try to rebuild, it will fail because it cannot find the header files. 如果删除上面列出的目录并尝试重建,则它将失败,因为找不到头文件。

"Well, Duh! You deleted the directory that contains the header files!". “嗯,Du!您删除了包含头文件的目录!”。

True, but the way the client build is setup is such that the static library is compiled and placed within /builds/foo/bar/build directory (including header files), before the client application builds. 没错,但是客户端构建的设置方式是,在构建客户端应用程序之前,将静态库编译并放置在/ builds / foo / bar / build目录(包括头文件)中。 It SHOULD be finding these header files. 应该找到这些头文件。 They exist before the client is compiled, and the 'Header Search Path' is set correctly. 它们在编译客户端之前就已经存在,并且正确设置了“标题搜索路径”。

As I said before, if I delete the directory that contains the lib and header files, and try a clean build of the client application, it fails. 如前所述,如果删除包含lib和头文件的目录,并尝试全新构建客户端应用程序,它将失败。 Although the build fails, the /builds/foo/bar/build directory gets created and populated, meaning all subsequent builds and cleans succeed. 尽管构建失败,但/ builds / foo / bar / build目录已创建并填充,这意味着所有后续构建和清理均成功。

Any idea how to fix this issue? 任何想法如何解决此问题?

Usually Xcode 4 handles the building of dependent projects correctly; 通常,Xcode 4可以正确处理依赖项目的构建。 but I have found circumstances where it does not. 但我发现情况并非如此。 You could try editing the scheme and making the static library dependency explicit. 您可以尝试编辑方案并明确显示静态库依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM