cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · how do cocoapods work?...
TRANSCRIPT
![Page 1: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/1.jpg)
CocoapodsPawel Dudek
1
1Tuesday, August 20, 13
![Page 2: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/2.jpg)
How can we manage dependencies in
Cocoa?
2
2Tuesday, August 20, 13
![Page 3: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/3.jpg)
3
Copy & Paste Submodules
3Tuesday, August 20, 13
![Page 4: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/4.jpg)
Copy & Paste1. Copy & Paste files
2. Add other linker flags
3. Add ARC flags
4. Add frameworks
5. Add any other missing build settings
6. Add resources
7. Finally, use the component
4
4Tuesday, August 20, 13
![Page 5: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/5.jpg)
Copy & Paste Issues
5
• Issues with duplicate symbols
• Really hard to manage versions
• Missing other linker flags and build settings
• Missing resources
5Tuesday, August 20, 13
![Page 6: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/6.jpg)
Submodules
• Issues with duplicate symbols
• Somewhat easier to manage versions (if they’re properly tagged)
• Other linker flags
• And other build settings
• Resources
6
6Tuesday, August 20, 13
![Page 7: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/7.jpg)
Submodules1. Add submodule (and check it out)
2. Add source to project
3. Add ARC flags
4. Add frameworks
5. Add other linker flags
6. Add any other missing build settings
7. Fix duplicate symbols
8. Add resources
9. Finally, use the component
7
7Tuesday, August 20, 13
![Page 8: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/8.jpg)
This is all wrong.
8
8Tuesday, August 20, 13
![Page 9: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/9.jpg)
We are to create things.
9
9Tuesday, August 20, 13
![Page 10: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/10.jpg)
This is all just wasting our time.
10
10Tuesday, August 20, 13
![Page 11: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/11.jpg)
Enter Cocoapods
11
11Tuesday, August 20, 13
![Page 12: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/12.jpg)
Cocoapods goals
12
• Make working with dependencies simple.
• Improve library discoverability and engagement by providing an ecosystem that facilitates this.
12Tuesday, August 20, 13
![Page 13: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/13.jpg)
Cocoapods advantages
• Automatically handle source code and static libraries
• Automatically handle ARC
• Automatically handle frameworks
• Automatically handle builds settings
• Automatically handle resources
13
13Tuesday, August 20, 13
![Page 14: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/14.jpg)
Cocoapods advantagesThe responsibility for configuration requirements lie
with the creator of component, not you.
14
14Tuesday, August 20, 13
![Page 15: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/15.jpg)
How can I install them?
15
gem install cocoapods
15Tuesday, August 20, 13
![Page 16: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/16.jpg)
Basics
16
16Tuesday, August 20, 13
![Page 17: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/17.jpg)
How do Cocoapods work?
• Pod - single definition of a component
• Podfile - list of dependencies
• Dependencies use semantic versioning
• Resolving dependencies lists all your dependencies and their dependencies
• Dependencies definitions are a Github repository
17
<major>.<minor>.<patch>
eg 1.2.5
17Tuesday, August 20, 13
![Page 18: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/18.jpg)
What happens when I install pods?
• Resolve dependencies from Podfile
• Take an .xcodeproj as a start
• Generate .xcconfing files and attaches them to your project
• Generate another .xcoproject with static library from defined dependencies
18
18Tuesday, August 20, 13
![Page 19: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/19.jpg)
What happens when I install pods?
• Generate an .xcworkspace with your project and generated .xcodeproject
• Add a dependency on the generated project results to your targets
• Lock used versions in Podfile.lock
19
19Tuesday, August 20, 13
![Page 20: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/20.jpg)
Basic commands
20
Installing pods
pod update
pod install
Updating pods
20Tuesday, August 20, 13
![Page 21: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/21.jpg)
pod install
• When there is no Podfile.lock - will use latest version or version defined in Podfile
• When there is a Podfile.lock - will use version from Podfile.lock or version defined in Podfile
21
21Tuesday, August 20, 13
![Page 22: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/22.jpg)
pod update
• Ignored Podfile.lock
• Will work as ‘pod install’ without a Podfile.lock
22
22Tuesday, August 20, 13
![Page 23: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/23.jpg)
Podfile
• Defines platform
• Defines project (optional)
• Defines dependencies
• Defines specific version
• Multiple targets
23Tuesday, August 20, 13
![Page 24: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/24.jpg)
Podfile example
24
24Tuesday, August 20, 13
![Page 25: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/25.jpg)
platform :ios, '5.0'xcodeproj 'TwitterUserTimeline'
pod 'STTwitter'pod 'Mantle', '1.2'
target :cedar do! link_with 'TwitterUserTimelineSpecs' pod 'Cedar'end
Podfile
iOS Version
25Tuesday, August 20, 13
![Page 26: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/26.jpg)
platform :ios, '5.0'xcodeproj 'TwitterUserTimeline'
pod 'STTwitter'pod 'Mantle', '1.2'
target :cedar do! link_with 'TwitterUserTimelineSpecs' pod 'Cedar'end
Podfile
Project
26Tuesday, August 20, 13
![Page 27: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/27.jpg)
platform :ios, '5.0'xcodeproj 'TwitterUserTimeline'
pod 'STTwitter'pod 'Mantle', '1.2'
target :cedar do! link_with 'TwitterUserTimelineSpecs' pod 'Cedar'end
Podfile
Dependencies
27Tuesday, August 20, 13
![Page 28: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/28.jpg)
platform :ios, '5.0'xcodeproj 'TwitterUserTimeline'
pod 'STTwitter'pod 'Mantle', '1.2'
target :cedar do! link_with 'TwitterUserTimelineSpecs' pod 'Cedar'end
Podfile
Exclusive target
28Tuesday, August 20, 13
![Page 29: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/29.jpg)
platform :ios, '5.0'xcodeproj 'TwitterUserTimeline'
pod 'STTwitter'pod 'Mantle', '1.2'
target :cedar do! link_with 'TwitterUserTimelineSpecs' pod 'Cedar'end
Podfile
Exclusive target name
29Tuesday, August 20, 13
![Page 30: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/30.jpg)
platform :ios, '5.0'xcodeproj 'TwitterUserTimeline'
pod 'STTwitter'pod 'Mantle', '1.2'
target :cedar do! link_with 'TwitterUserTimelineSpecs' pod 'Cedar'end
Podfile
Exclusive pod
30Tuesday, August 20, 13
![Page 31: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/31.jpg)
Cleaning up
31
By wiping whole Cocoapods caches
rm -rf Pods/rm -rf ~/Library/Caches/CocoaPods/Git/rm -rf ~/Library/Caches/CocoaPods/GitHub/rm -rf ~/.cocoapods/
31Tuesday, August 20, 13
![Page 32: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/32.jpg)
Moving patch version
Will automatically update to new available patch version
32
pod 'Mantle', '~> 1.2.0'
32Tuesday, August 20, 13
![Page 33: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/33.jpg)
Fun stuff
33
33Tuesday, August 20, 13
![Page 34: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/34.jpg)
Using Cocoapodsfor in-house components
34
Encourages reusable code
Over 28 components at Taptera
Really encourage to use it!
34Tuesday, August 20, 13
![Page 35: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/35.jpg)
What you’ll need
35
• Cocoapods installed
• Git repo for specs definitions
• And you’re all set!
35Tuesday, August 20, 13
![Page 36: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/36.jpg)
Your own Cocoapods Pod spec
36
36Tuesday, August 20, 13
![Page 37: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/37.jpg)
Example
37
37Tuesday, August 20, 13
![Page 38: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/38.jpg)
Things you’ll have to do first
• Add your own specs repo to local cocoapods repo list
• Push the podspec to your repository
38
38Tuesday, August 20, 13
![Page 39: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/39.jpg)
Adding custom specs repo
39
pod repo add <repo_name> <repo_address>
39Tuesday, August 20, 13
![Page 40: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/40.jpg)
Pushing to Cocoapods specs repo
40
pod push <repo_name>
40Tuesday, August 20, 13
![Page 41: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/41.jpg)
Demo
41
41Tuesday, August 20, 13
![Page 42: Cocoapods - mobile-warsaw.plmobile-warsaw.pl/files/dudek_cocoapods.pdf · How do Cocoapods work? • Pod - single definition of a component • Podfile - list of dependencies •](https://reader035.vdocument.in/reader035/viewer/2022062317/5f09bf787e708231d4285457/html5/thumbnails/42.jpg)
Resources & Contact
@eldudi
github.com/paweldudek
Code Examples
Contact
42
42Tuesday, August 20, 13