在静态库中包含第三方库(例如:AFNetworking) [英] Including Third party libraries(Example : AFNetworking) in static library

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

问题描述

是否可以在静态库中包含第 3 方库?示例:AFNetworking 可以包含在静态库中吗

Is it possible to include 3rd party libraries in static library? Example : Can AFNetworking can be included in static library

推荐答案

对你的问题的直接回答是肯定的,你绝对可以包含任何第三方库,如果它们公开一个公共 API(一组标题供你参考).对于 AFNetworking,他们提供了一个 Cocoapods 脚本,让您的项目可以引用它,从而使其变得如此简单.

The direct answer to your question is YES, you can definitely include any third party library if they expose a public API (a set of headers for you to refer). For AFNetworking, they have made it so simple by providing a Cocoapods script so that your project can refer it.

但请注意,当您发布包含 AFNetwork 的静态库时,如果有一天您的静态库用户决定在他自己的代码中使用 AFNetwork,Obj-C 编译器会抱怨重复符号,他将无法用你的静态库构建他的项目.

But be aware that when you release your static library with including AFNetwork inside, and someday if your static lib user decides to use AFNetwork in his own code, the Obj-C compiler will complain about duplicate symbols and he will be unable to build his project with your static lib.

我的建议

我的建议:请参考上面@Amar 分享的链接.如果您希望与其他开发人员或社区共享,请不要在您的静态库中包含任何第三方库,这一点非常重要.始终考虑使用其他第三方静态库的引用而不是包含它们,例如使用 Cocoapods.

My advice :just refer to the link shared by @Amar above. It is very important NOT to include any third party libraries in your static library if you are hoping to share it with other developers or community. Always consider using references for other third party static libraries instead of including them, for example make use of Cocoapods.

这篇关于在静态库中包含第三方库(例如:AFNetworking)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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