在 Xcode 静态库中包含框架?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1908521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Include framework in Xcode static library?
提问by Jon-Eric
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?
有没有办法在 Xcode 中创建一个静态库,这样当客户端链接到该库时,它们也链接到该库所依赖的框架?
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.
我们有一个共享的 Xcode 项目,其中包含多个包含我们所有公共代码的静态库目标。例如,如果一个项目想要使用共享网络代码,他们所要做的就是在我们的网络库中链接。
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.
例如,我们的声音库使用 AudioToolkit.framework。即使 Sound 库在其链接库的列表中包含 AudioToolbox.framework,如果客户端不直接与 AudioToolkit.framework 链接,客户端在与 Sound 链接时也会出现链接器错误。
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!
谢谢!
采纳答案by Gregory Pakosz
回答by Bob de Graaf
A new answer to this question would be, yes it's possible: use cocoapods! :)
这个问题的新答案是,是的,有可能:使用 cocoapods!:)