I know cocoapod is simplifying the efforts of manually adding libraries or let developer concentrate on his actual source code.
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
Isn't it creating code redundancy or increasing my iPA size or other performance issues?
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.
So, in general, be carefull when adding a big library to you project via CocoaPods.
AFNetworking is divided into subspecs, so you should be able to get just the reachability part with:
pod 'AFNetworking/Reachability'
or you can get a different more focused pod, search for reachability on cocoapods.org
In terms of general code waste: I wouldn't be too worried about IPA size for relatively small libraries like AFNetworking (270K on disk of source). In terms of including code you don't use I guess you should try and find a library that most closely matches your needs. If you have a choice between writing exactly the networking code you need, or use a tried and proven framework even though you don't use it all, i'd take the framework
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With