Dependencies
       management
      with CocoaPods

Denis Lebedev
Why do we need it?
Drag & drop
Git submodule
3rd-party
(do they exist at all?)
CocoaPods
http://cocoapods.org
Install
$ sudo gem install cocoapods
Create Podfile
platform :ios
pod 'AFNetworking'
pod 'MBProgressHUD'
pod 'OHAttributedLabel'
pod 'MagicalRecord', '= 1.8.3'
pod 'EGOImageLoading'
pod 'AQGridView'
pod 'Facebook-iOS-SDK'
pod 'DCIntrospect'
pod 'OCMock'
Add libs to the project
     $ pod install
How it works
Write own specs
$ pod spec create MySpec
$vim MySpec.podspec
$pod spec lint
MySpec.podspec
Spec example
Contribute
(>650 podspecs already)
Podfile options
Platform
platform :ios, 4.0

       Versioning
pod ‘EgoImageView’, ‘<=1.2’
pod ‘EgoImageView’, :head
Multiple targets
pod 'RestKit'

target :debug do
    pod 'CocoaLumberjack'
end

target :test, :exclusive => true do
    link_with “MyAppTests”
    pod 'Kiwi'
end
Turn off all warnings in
      lib sources
     inhibit_all_warnings!
Podspec sources
Spec in the root
       of lib repo
pod 'AFNetworking', :git => 'https://
github.com/gowalla/
Lib without podspec
pod 'JSONKit', :podspec => 'https://
raw.github.com/gist/
1346394/1d26570f68ca2d72/
Lib without any
    available podspec
pod do |spec|
    spec.name        = 'JSONKit'
    spec.version      = '1.4'
    spec.source      = { :git =>
'https://github.com/    johnezang/
JSONKit.git', :tag => 'v1.4' }
spec.source_files = 'JSONKit.*'
end
Local pod
pod 'libAwesome', :local => '~/path/
            libAwesome'



*podspec should be in the folder
Pod specification
Dependencies
...
s.dependency = ‘JSONKit’, ‘<1.4’
...
Spec template
~pod spec create https://github.com/repo
Subspecs
pod ‘RestKit/JSON’

Pod::Spec.new do |s|
     s.name = 'RestKit'
     s.preferred_dependency = 'JSON'
     ...
     s.subspec 'JSON' do |js|
         js.dependency 'RestKit/ObjectMapping/JSON'
         js.dependency 'RestKit/ObjectMapping/CoreData'
         js.dependency 'RestKit/UI'
     end
     s.subspec 'XML' do |xs|
          ...
     end
    ...
end
More

weak_frameworks


s.osx.source_files = ‘MyNSTableView.
{h,m}’
Share pod
specifications
‘Private’ specs repo
$ pod repo add my-spec-repo http://
github.com/my-account/spec-repo.git

$ pod push my-spec-repo

$ cd ~/.cocoapods/my-spec-repo
$ git remote add upstream git://
github.com/CocoaPods/Specs.git
Public specs repo*
  $ cd ~/.cocoapods/master
  $ git remote set-url origin
  git@github.com:CocoaPods/Specs.git


*If you have push access to master-repo
‘Appstore’ for libs
Thanks!
            Questions?



twitter: @delebedev
skype: d2.lebedev

Денис Лебедев-Управление зависимостями с помощью CocoaPods