If you ever wondered how to easily develop and manage your own libraries for iOS and OS X seek no further! Watch the presentation and read our blog to find a solution. If you have any questions just drop me an email or tweet :)
2. • What is CocoaPods?
• Local CocoaPods dependencies.
• Building a distribution library.
• One library - 5 different architectures.
• Avoiding collisions in other projects.
• Final thoughts.
Roadmap:
3. CocoaPods is the dependency manager for
Objective-C projects. It has thousands of
libraries and can help you scale your projects
elegantly. [http://cocoapods.org]
4. Podfile:
pod 'CocoaLumberjack', '~> 1.7.0'
pod 'AFNetworking', '~> 1.3.3'
pod 'UIView+AutoLayout', '~> 1.1.0'
pod 'MagicalRecord', '~> 2.2'
pod 'Reachability', '~> 3.1.1'
pod 'UIAlertView-Blocks', '~> 0.0.1'
Terminal:
$ pod install
5. Semantic versioning:
!
• Major.Minor.Patch -> 2.0.1
• Major - incompatible API changes
• Minor - added features but backward compatible
• Patch - backward compatible bug fixes
int add(int a, int b) { return a-b; } // 1.0.0
double add(int a) { return 3.14+a; }
int add(int a, int b, int c=0) { return a+b+c; }
int add(int a, int b) { return a+b; } // x.y.z
16. Symbols investigation
$ nm libNetworkLib-debug-0.1.a | grep AFN
!
!
000000000000bea0 s -[UIWebView(_AFNetworking)
af_HTTPRequestOperation].eh
!
0000000000000030 t -[UIWebView(_AFNetworking)
af_setHTTPRequestOperation:]
!
000000000000bec8 s -[UIWebView(_AFNetworking)
af_setHTTPRequestOperation:].eh
!
0000000000000190 t ___44-[UIWebView(AFNetworking)
requestSerializer]_block_invoke
!
000000000000bf18 s ___44-[UIWebView(AFNetworking)
requestSerializer]_block_invoke.eh
17. Symbol collisions solutions
• Pretend they don’t exist ;)
• Write in docs which dependencies are required
• Export all dependencies’ headers
• Build library with prefixed symbols
22. • Easy development
• Clean git repo
• Easy switching from local podspec to static
library
• Shell & classic build script sometimes
necessary
• Only one step to put your lib to global repo
Summary