SlideShare a Scribd company logo
1 of 30
Download to read offline
Using CocoaPods
Library Dependency Management for Xcode

with Jeffrey Sambells!
http://JeffreySambells.com
Why CocoaPods?
Build dependencies
Error-prone

+
Difficult upgrade path

Cluttered project

Link binary with libraries

=
Header search path

Libraries in version control
No transitive dependencies
Automatic add/remove

Automatic build configuration

Project is always shippable!
Discoverability

+

+

Large ecosystem

=

Separation of third-party code

Handles ARC and no ARC
Only includes the relevant source files
Installation…
$ sudo gem update -- system
$ sudo gem install cocoapods
$ pod setup
Using CocoaPods
in Xcode
Cocoapods Workflow
1. Create your Podfile
2. Search for and add your dependencies
3. Run pod command
4. Open your new .xcworkspace (it will be created)
5. ???
6. Profit!
Creating the Podfile
$ cd /path/to/project/folder
$ touch Podfile
Simple
pod 'AFNetworking'
pod 'ObjectiveSugar', '~> 0.5'
Advanced
platform :ios, '7.0'
inhibit_all_warnings!
!
workspace 'Example.xcworkspace'
!
pod 'AFNetworking', :git => 'https://github.com/gowalla/
AFNetworking.git', :commit => '082f8319af'
!
pod 'MySecretPod', :path => ‘~/Documents/MySecretPod'
!
pod 'BleedingEdgePod', :head
!
target :KIFTests, :exclusive => false do
pod 'KIF'
end
!
post_install do |installer|
installer.project.targets.each do |target|
puts "#{target.name}"
end
end
Install/Update into Project
$ cd /path/to/project/folder
$ pod

Hint: use pod --verbose if you want more info.
The Podfile and
Dependencies
General Settings
Specify a platform and minimum version

platform :ios, '6.1'
!

Optionally specify project and workspace files.

For example MyProject.xcodeproj and
MyProject.xcworkspace

xcodeproj 'MyProject'
workspace 'MyWorkspace'
Dependencies (Pods)
Specify pod name and other options as
necessary:


•




pod ‘PodName'

Some pods use sub specs to group optional
functionality so you need to specify them as well:


•







 pod

‘PodName'
pod ‘PodName/SubSpecA’
pod ‘PodName/SubSpecB‘
Pod Versioning x.x.x
•

References a specific git tag using a semantic version.

•

Specify no version, a specific version, a logical version
or an optimistic version.








pod
pod
pod
pod




•

‘PodName’
‘PodName’, ‘0.1.0’
‘PodName’, ‘<= 0.1.0’
‘PodName’, ‘~> 0.1.0’

You can also use :head to get the most bleeding edge
version.
pod ‘PodName’, :head
Logical Versions
•

'> 0.1' Any version higher than 0.1

•

'>= 0.1' Version 0.1 and any higher version

•

'< 0.1' Any version lower than 0.1

•

'<= 0.1' Version 0.1 and any lower version
Optimistic Versions
•

'~> 0.1.2' Version 0.1.2 and the versions up to
0.2, not including 0.2 and higher

•

'~> 0.1' Version 0.1 and the versions up to 1.0,
not including 1.1 and higher

•

'~> 0' Version 0 and higher, this is basically the
same as not having it.
Pod Sources
Pods load information from a podspec file.

The podspec files are located in…
•

the shared public spec repo at 

https://github.com/CocoaPods/Specs,

•

on your local machine,

•

in a private git repo.
Public Shared Specs
you only need to specify the name:


•

pod 'AFNetworking'

you can optionally specify a specific branch or
fork:


•




•

pod ‘AFNetworking’, :git => ‘https://github.com/
iamamused/AFNetworking.git'

and a specific commit:

pod ‘AFNetworking’, :git => ‘https://github.com/
myuser/AFNetworking.git', :commit => '082f8319af'
Local Podspecs
Load a podspec from your local machine
using :path






pod ‘MyAwesomePod’, path: => ‘../path/
MyAwesomePod.podspec’
Private Podspecs
Load a podspec from a private git repository using
:git (simiar to public specs)





pod ‘MyAwesomePod’, git: => ‘http://example.com/
MyAwesomePod.git’
Bonus
Code doesn’t have a pod? no problem. Make your
own pod spec for it and use that:
!
pod 'ExampleKit', :podspec => !'https://raw.github.com/gist/
123/ExampleKit.podspec'
Targets
Targets allow you to specify which Xcode target
have which pod dependencies.
Pod dependencies are applied to 

individual or multiple targets.
If no specific target is specified it 

only applies to the first target in your project!
Targets
Use link_with to specify multiple targets for all
pod dependencies:



pod ‘PodName’
link_with [‘MyApp’,’MyAppDemo’]
Targets
Or use target :targetname to specify targets
individually:
pod ‘PodName’
!
target :test, :exclusive => true do
pod 'Kiwi'
end
!

•

exclusive => true will only include pods declared in
the target block.

•

exclusive => false will include pods declared in the
target block along with those declared in the parent.
Hooks
pre_install

Make any changes to the Pods after they have
been downloaded but before they are installed.
!
!

pre_install do |installer_representation|
# Do something fancy!
end
Hooks
post_install

Make any changes to the generated Pods project,
or any other tasks you might want to perform.
!

post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
end
end
end
Pod Best Practices
•

Check the source, documentation and upkeep
of a pod! Don’t blindly use them.

•

Include pods in source control? NO! err YES!

•

Use inhibit_all_warnings! to hide warnings in
Pods (after you check them).
DEMO TIME!
Thanks!
More Info"
cocoapods.org
JeffreySambells.com
@iamamused

More Related Content

What's hot

ATDD with Behat and Selenium (LDNSE6)
ATDD with Behat and Selenium (LDNSE6)ATDD with Behat and Selenium (LDNSE6)
ATDD with Behat and Selenium (LDNSE6)Shashikant Jagtap
 
OpenShift: Java EE in the clouds
OpenShift: Java EE in the cloudsOpenShift: Java EE in the clouds
OpenShift: Java EE in the cloudsMax Andersen
 
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 -  Rock Solid Deployment of Symfony AppsSymfony Live NYC 2014 -  Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony AppsPablo Godel
 
Package Management on Windows with Chocolatey
Package Management on Windows with ChocolateyPackage Management on Windows with Chocolatey
Package Management on Windows with ChocolateyPuppet
 
Introduction to bower
Introduction to bowerIntroduction to bower
Introduction to bowerJitendra Zaa
 
Kinect Workshop Part 1/2
Kinect Workshop Part 1/2Kinect Workshop Part 1/2
Kinect Workshop Part 1/2Seiya Konno
 
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...Jan Vosecky
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsPablo Godel
 
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev Environment
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev EnvironmentPhoneGap Day 2016 EU: Creating the Ideal Cordova Dev Environment
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev EnvironmentRyan J. Salva
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Dockerizing BDD : Ruby-Cucumber Example
Dockerizing BDD : Ruby-Cucumber ExampleDockerizing BDD : Ruby-Cucumber Example
Dockerizing BDD : Ruby-Cucumber ExampleShashikant Jagtap
 
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...Pablo Godel
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding styleBo-Yi Wu
 
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Robert Reiz
 
Docker Tooling for Eclipse
Docker Tooling for EclipseDocker Tooling for Eclipse
Docker Tooling for EclipseMax Andersen
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
Testing all your code through HipChat in Docker
Testing all your code through HipChat in DockerTesting all your code through HipChat in Docker
Testing all your code through HipChat in DockerMike Pavlenko
 

What's hot (20)

ATDD with Behat and Selenium (LDNSE6)
ATDD with Behat and Selenium (LDNSE6)ATDD with Behat and Selenium (LDNSE6)
ATDD with Behat and Selenium (LDNSE6)
 
OpenShift: Java EE in the clouds
OpenShift: Java EE in the cloudsOpenShift: Java EE in the clouds
OpenShift: Java EE in the clouds
 
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 -  Rock Solid Deployment of Symfony AppsSymfony Live NYC 2014 -  Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
 
Mastering composer
Mastering composerMastering composer
Mastering composer
 
Package Management on Windows with Chocolatey
Package Management on Windows with ChocolateyPackage Management on Windows with Chocolatey
Package Management on Windows with Chocolatey
 
Introduction to bower
Introduction to bowerIntroduction to bower
Introduction to bower
 
Kinect Workshop Part 1/2
Kinect Workshop Part 1/2Kinect Workshop Part 1/2
Kinect Workshop Part 1/2
 
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
How to Build & Deploy a HelloWorld API function using Java on OpenShift in...
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
 
GitHub Presentation
GitHub PresentationGitHub Presentation
GitHub Presentation
 
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev Environment
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev EnvironmentPhoneGap Day 2016 EU: Creating the Ideal Cordova Dev Environment
PhoneGap Day 2016 EU: Creating the Ideal Cordova Dev Environment
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Dockerizing BDD : Ruby-Cucumber Example
Dockerizing BDD : Ruby-Cucumber ExampleDockerizing BDD : Ruby-Cucumber Example
Dockerizing BDD : Ruby-Cucumber Example
 
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
 
Cocoa pods
Cocoa podsCocoa pods
Cocoa pods
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding style
 
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014
 
Docker Tooling for Eclipse
Docker Tooling for EclipseDocker Tooling for Eclipse
Docker Tooling for Eclipse
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Testing all your code through HipChat in Docker
Testing all your code through HipChat in DockerTesting all your code through HipChat in Docker
Testing all your code through HipChat in Docker
 

Similar to Using Cocoapods

Cocoapods Overview - library dependency manager for iOS
Cocoapods Overview - library dependency manager for iOSCocoapods Overview - library dependency manager for iOS
Cocoapods Overview - library dependency manager for iOSPrajwal S Prakash
 
What is CocoaPods and how to setup?
What is CocoaPods and how to setup?What is CocoaPods and how to setup?
What is CocoaPods and how to setup?Milan Panchal
 
Cocoapods in action
Cocoapods in actionCocoapods in action
Cocoapods in actionHan Qin
 
CocoaHeads Rennes #13 : CocoaPods
CocoaHeads Rennes #13 : CocoaPodsCocoaHeads Rennes #13 : CocoaPods
CocoaHeads Rennes #13 : CocoaPodsCocoaHeadsRNS
 
Dependent things dependency management for apple sw - slideshare
Dependent things   dependency management for apple sw - slideshareDependent things   dependency management for apple sw - slideshare
Dependent things dependency management for apple sw - slideshareCavelle Benjamin
 
How cocoapods can enhance your iOS development - Amir Hayek, Toluna
How cocoapods can enhance your iOS development - Amir Hayek, TolunaHow cocoapods can enhance your iOS development - Amir Hayek, Toluna
How cocoapods can enhance your iOS development - Amir Hayek, TolunaCodemotion Tel Aviv
 
Cocoa tip for Cocoaheads Shanghai February 2016
Cocoa tip for Cocoaheads Shanghai February 2016Cocoa tip for Cocoaheads Shanghai February 2016
Cocoa tip for Cocoaheads Shanghai February 2016Antoine Cœur
 
DevNet Associate : Python introduction
DevNet Associate : Python introductionDevNet Associate : Python introduction
DevNet Associate : Python introductionJoel W. King
 
How to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy stepsHow to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy stepsDeveo
 
Денис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsДенис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsUA Mobile
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHPWilliam Lee
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)Fabien Potencier
 
How to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slatherHow to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slatherallanh0526
 
Dojo javascript toolkit
Dojo javascript toolkit Dojo javascript toolkit
Dojo javascript toolkit Predhin Sapru
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy VirinCocoaHeads France
 

Similar to Using Cocoapods (20)

Private pod support using cocoa pods in ios
Private pod support using cocoa pods in iosPrivate pod support using cocoa pods in ios
Private pod support using cocoa pods in ios
 
CocoaPods.pptx
CocoaPods.pptxCocoaPods.pptx
CocoaPods.pptx
 
Cocoapods Overview - library dependency manager for iOS
Cocoapods Overview - library dependency manager for iOSCocoapods Overview - library dependency manager for iOS
Cocoapods Overview - library dependency manager for iOS
 
Creating Cocoapods Library
Creating Cocoapods LibraryCreating Cocoapods Library
Creating Cocoapods Library
 
What is CocoaPods and how to setup?
What is CocoaPods and how to setup?What is CocoaPods and how to setup?
What is CocoaPods and how to setup?
 
Cocoapods in action
Cocoapods in actionCocoapods in action
Cocoapods in action
 
CocoaHeads Rennes #13 : CocoaPods
CocoaHeads Rennes #13 : CocoaPodsCocoaHeads Rennes #13 : CocoaPods
CocoaHeads Rennes #13 : CocoaPods
 
Dependent things dependency management for apple sw - slideshare
Dependent things   dependency management for apple sw - slideshareDependent things   dependency management for apple sw - slideshare
Dependent things dependency management for apple sw - slideshare
 
How cocoapods can enhance your iOS development - Amir Hayek, Toluna
How cocoapods can enhance your iOS development - Amir Hayek, TolunaHow cocoapods can enhance your iOS development - Amir Hayek, Toluna
How cocoapods can enhance your iOS development - Amir Hayek, Toluna
 
Cocoa tip for Cocoaheads Shanghai February 2016
Cocoa tip for Cocoaheads Shanghai February 2016Cocoa tip for Cocoaheads Shanghai February 2016
Cocoa tip for Cocoaheads Shanghai February 2016
 
DevNet Associate : Python introduction
DevNet Associate : Python introductionDevNet Associate : Python introduction
DevNet Associate : Python introduction
 
Practical Cocoapods
Practical CocoapodsPractical Cocoapods
Practical Cocoapods
 
How to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy stepsHow to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy steps
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
 
Денис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsДенис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPods
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHP
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 
How to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slatherHow to generate code coverage reports in xcode with slather
How to generate code coverage reports in xcode with slather
 
Dojo javascript toolkit
Dojo javascript toolkit Dojo javascript toolkit
Dojo javascript toolkit
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy Virin
 

Recently uploaded

E J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxE J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxJackieSparrow3
 
Inspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxInspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxShubham Rawat
 
南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证kbdhl05e
 
(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)oannq
 
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...JeylaisaManabat1
 
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan
 

Recently uploaded (6)

E J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxE J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptx
 
Inspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxInspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptx
 
南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证
 
(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)
 
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
 
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
 

Using Cocoapods

  • 1. Using CocoaPods Library Dependency Management for Xcode with Jeffrey Sambells! http://JeffreySambells.com
  • 3. Build dependencies Error-prone + Difficult upgrade path Cluttered project Link binary with libraries = Header search path Libraries in version control No transitive dependencies
  • 4. Automatic add/remove Automatic build configuration Project is always shippable! Discoverability + + Large ecosystem = Separation of third-party code Handles ARC and no ARC Only includes the relevant source files
  • 5. Installation… $ sudo gem update -- system $ sudo gem install cocoapods $ pod setup
  • 7. Cocoapods Workflow 1. Create your Podfile 2. Search for and add your dependencies 3. Run pod command 4. Open your new .xcworkspace (it will be created) 5. ??? 6. Profit!
  • 8. Creating the Podfile $ cd /path/to/project/folder $ touch Podfile
  • 10. Advanced platform :ios, '7.0' inhibit_all_warnings! ! workspace 'Example.xcworkspace' ! pod 'AFNetworking', :git => 'https://github.com/gowalla/ AFNetworking.git', :commit => '082f8319af' ! pod 'MySecretPod', :path => ‘~/Documents/MySecretPod' ! pod 'BleedingEdgePod', :head ! target :KIFTests, :exclusive => false do pod 'KIF' end ! post_install do |installer| installer.project.targets.each do |target| puts "#{target.name}" end end
  • 11. Install/Update into Project $ cd /path/to/project/folder $ pod Hint: use pod --verbose if you want more info.
  • 13. General Settings Specify a platform and minimum version
 platform :ios, '6.1' ! Optionally specify project and workspace files.
 For example MyProject.xcodeproj and MyProject.xcworkspace
 xcodeproj 'MyProject' workspace 'MyWorkspace'
  • 14. Dependencies (Pods) Specify pod name and other options as necessary:
 • 
 pod ‘PodName' Some pods use sub specs to group optional functionality so you need to specify them as well:
 • 
 
 
 pod ‘PodName' pod ‘PodName/SubSpecA’ pod ‘PodName/SubSpecB‘
  • 15. Pod Versioning x.x.x • References a specific git tag using a semantic version. • Specify no version, a specific version, a logical version or an optimistic version.
 
 
 
 pod pod pod pod 
 • ‘PodName’ ‘PodName’, ‘0.1.0’ ‘PodName’, ‘<= 0.1.0’ ‘PodName’, ‘~> 0.1.0’ You can also use :head to get the most bleeding edge version. pod ‘PodName’, :head
  • 16. Logical Versions • '> 0.1' Any version higher than 0.1 • '>= 0.1' Version 0.1 and any higher version • '< 0.1' Any version lower than 0.1 • '<= 0.1' Version 0.1 and any lower version
  • 17. Optimistic Versions • '~> 0.1.2' Version 0.1.2 and the versions up to 0.2, not including 0.2 and higher • '~> 0.1' Version 0.1 and the versions up to 1.0, not including 1.1 and higher • '~> 0' Version 0 and higher, this is basically the same as not having it.
  • 18. Pod Sources Pods load information from a podspec file.
 The podspec files are located in… • the shared public spec repo at 
 https://github.com/CocoaPods/Specs, • on your local machine, • in a private git repo.
  • 19. Public Shared Specs you only need to specify the name:
 • pod 'AFNetworking' you can optionally specify a specific branch or fork:
 • 
 • pod ‘AFNetworking’, :git => ‘https://github.com/ iamamused/AFNetworking.git' and a specific commit:
 pod ‘AFNetworking’, :git => ‘https://github.com/ myuser/AFNetworking.git', :commit => '082f8319af'
  • 20. Local Podspecs Load a podspec from your local machine using :path
 
 
 pod ‘MyAwesomePod’, path: => ‘../path/ MyAwesomePod.podspec’
  • 21. Private Podspecs Load a podspec from a private git repository using :git (simiar to public specs)
 
 
 pod ‘MyAwesomePod’, git: => ‘http://example.com/ MyAwesomePod.git’
  • 22. Bonus Code doesn’t have a pod? no problem. Make your own pod spec for it and use that: ! pod 'ExampleKit', :podspec => !'https://raw.github.com/gist/ 123/ExampleKit.podspec'
  • 23. Targets Targets allow you to specify which Xcode target have which pod dependencies. Pod dependencies are applied to 
 individual or multiple targets. If no specific target is specified it 
 only applies to the first target in your project!
  • 24. Targets Use link_with to specify multiple targets for all pod dependencies:
 
 pod ‘PodName’ link_with [‘MyApp’,’MyAppDemo’]
  • 25. Targets Or use target :targetname to specify targets individually: pod ‘PodName’ ! target :test, :exclusive => true do pod 'Kiwi' end ! • exclusive => true will only include pods declared in the target block. • exclusive => false will include pods declared in the target block along with those declared in the parent.
  • 26. Hooks pre_install Make any changes to the Pods after they have been downloaded but before they are installed. ! ! pre_install do |installer_representation| # Do something fancy! end
  • 27. Hooks post_install Make any changes to the generated Pods project, or any other tasks you might want to perform. ! post_install do |installer_representation| installer_representation.project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported' end end end
  • 28. Pod Best Practices • Check the source, documentation and upkeep of a pod! Don’t blindly use them. • Include pods in source control? NO! err YES! • Use inhibit_all_warnings! to hide warnings in Pods (after you check them).