使用cocoapods ios [英] working with cocoapods ios
问题描述
我知道cocoapod正在简化手动添加库的工作,或者让开发人员专注于他的实际源代码。
I know cocoapod is simplifying the efforts of manually adding libraries or let developer concentrate on his actual source code.
但是我的问题是,我是否只需要一些源代码某个项目中的文件是否可以通过安装相同的cocoapod添加整个库?
就像如果我只需要 Reachability
类文件,那为什么我应该全部使用 AFNetworking
But my question is if I need only some of source file from certain project then is good to add whole library by installing same cocoapod?
Like if I need only Reachability
class file then why should I take whole AFNetworking
不是在创建代码冗余或增加我的iPA大小或其他性能问题吗?
推荐答案
通常,在Objective-C中向您的项目添加静态库会将所有对象文件提取到生成的二进制文件中,因为可可豆荚安装会在链接器设置中添加-ObjC标志,如链接器中所述手册:
In general, adding a static library to your project in Objective-C will pull ALL OBJECT FILES into your resulting binary because cocoa pods installation adds -ObjC flag to your linker settings, and as stated in linker manual:
-ObjC Loads all members of static archive libraries that implement
an Objective-C class or category.
此标志用于解决链接类别的问题,因为默认情况下链接器将不包含仅包含分类到结果二进制文件中的目标文件。
This flag included to solve problem with linking categories, because by default linker will not include object files containing only categories into resulting binary.
因此,通常,在通过CocoaPods向您的项目中添加大库时要小心。
So, in general, be carefull when adding a big library to you project via CocoaPods.
这篇关于使用cocoapods ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!