09 March 2015

what is cocoapods

CocoaPods manages library dependencies for your Xcode projects

installation

CocoaPods is build with Ruby

$ sudo gem install cocoapods

sudo-less installation

  • passing --user-install flag to gem install
  • configuring RubyGems env

create or edit .profile in your home directory

export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH

updating cocoapods

$ sudo gem install cocoapods
# to update cocoapods you simply install the gem again

$ sudo gem install cocoapods --pre
# for a pre-release version

using cocoapods

  1. create a Podfile add your dependencies

    pod ‘AFNetworking’, ‘~>2.0’

    pod ‘ObjectiveSugar’, ‘~>0.5’

  2. run in your project directory

    $ pod install

  3. open xcworkspace and build

    your_app.xcworkspace

creating a new project with cocoapods

1. create a new project
1. in terminal `$ cd` into your project dir
1. create a Podfile by running `$ touch Podfile`
1. add first line `platform :ios, '6.0'`
1. add a cocoapod by specifying `pod 'ObjectiveSugar'`
1. save Podfile
1. run `$ pod install`
1. open 'your_app.xcworkspace'

Podfile.lock

this file keeps track of what version of a pod is installed
if dependency is updated on the Podfile
or `pod update` is called
pods in Podfile.lock will update

stackoverflow

# /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/pathname.rb:422:in `open': No such file or directory ...

run $ pod setup before $ pod install


blog comments powered by Disqus