Include framework in Xcode static library?

我是研究僧i 提交于 2019-12-04 16:58:54

问题


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!


回答1:


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.




回答2:


A new answer to this question would be, yes it's possible: use cocoapods! :)

http://cocoapods.org



来源:https://stackoverflow.com/questions/1908521/include-framework-in-xcode-static-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!