在Xcode静态库中包含框架? [英] Include framework in Xcode static library?

查看:134
本文介绍了在Xcode静态库中包含框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之:



有没有办法在Xcode中创建静态库,这样当客户端链接到该库时,它们也会链接到框架上库取决于?



问题:



我们有一个共享的Xcode项目,其中包含多个包含所有的静态库目标我们共同的代码。例如,如果一个项目想要使用共享网络代码,他们应该做的就是在我们的网络库中链接。



问题是这些库没有似乎包含他们所依赖的框架。



例如,我们的Sound库使用AudioToolkit.framework。即使Sound库在其列表中包含AudioToolbox.framework,其链接库,如果它们也不与AudioToolkit.framework直接链接,则客户端在与Sound链接时会出现链接器错误。



<这是一个维护麻烦,因为每次库的框架依赖关系发生变化时,我们都会手动更改所有依赖项目中链接框架的列表。



这应该是否有效?有更好的方法吗?



谢谢!

解决方案

简而言之:不,静态库只是一堆 .o 文件



A解决方案是将您的公共代码重构为静态框架,请参阅那里寻找可能的解决方案。


In short:

Is there a way to create a static library in Xcode such that when clients link with that library, they also link with the frameworks upon which that library depends?

The problem:

We have a shared Xcode project which contains multiple static library targets containing all of our common code. E.g., If a project wants to use the shared networking code, all they should have to do is link in our Network library.

The problem is that the libraries don't seem to "include" the frameworks on which they depend.

E.g., our Sound library uses the AudioToolkit.framework. Even when the Sound library includes AudioToolbox.framework in the list its linked libraries, clients get linker errors when linking with Sound if they don't also directly link with AudioToolkit.framework.

This is a maintenance hassle because every time a library's framework dependencies change we have manually go change the list of linked frameworks in all dependent projects.

Is this supposed to work? Is there a better way?

Thanks!

解决方案

In short: no, a static library is just a bunch of .o files

A solution would be to refactor your common code into "static frameworks", see there for a possible solution.

这篇关于在Xcode静态库中包含框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆