Getting Started

<What is CocoaPods

CocoaPods manages library dependencies for your Xcode projects.

The dependencies for your projects are specified in a single text file called a Podfile. CocoaPods will resolve dependencies between libraries, fetch the resulting source code, then link it together in an Xcode workspace to build your project.

Ultimately the goal is to improve discoverability of, and engagement in, third party open-source libraries by creating a more centralised ecosystem.

<Prefer video?

Google have created a great overview for Route 85 video series going through this entire guide and more.

<Getting Started

<Installation

CocoaPods is built with Ruby and it will be installable with the default Ruby available on macOS. However, we recommend not using the system provided Ruby and instead installing a newer Ruby version separate from the system installation. You can use a Ruby Version manager such as RVM or rbenv to manage multiple Ruby versions, or you can use Homebrew to install a newer Ruby with brew install ruby.

Install CocoaPods by running the following command:

$ gem install cocoapods

If using the default Ruby included with macOS, installation will require you to use sudo when installing gems. (This is only an issue for the duration of the gem installation, though.)

$ sudo gem install cocoapods

If you encounter any problems during installation, please visit this guide.

<Sudo-less installation

If you do not want to grant RubyGems admin privileges for this process, you can tell RubyGems to install into your user directory by passing either the --user-install flag to gem install or by configuring the RubyGems environment. The latter is in our opinion the best solution. To do this open up terminal and create or edit your .bash_profile with your preferred editor. Then enter these lines into the file:

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

Note that if you choose to use the --user-install option, you will still have to configure your .bash_profile file to set the PATH or use the command prepended by the full path. You can find out where a gem is installed with gem which cocoapods. E.g.

$ gem install cocoapods --user-install
$ gem which cocoapods
/Users/eloy/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods.rb
$ /Users/eloy/.gem/ruby/2.0.0/bin/pod install

<Updating CocoaPods

To update CocoaPods you simply install the gem again

$ [sudo] gem install cocoapods

Or for a pre-release version

$ [sudo] gem install cocoapods --pre

If you originally installed the cocoapods gem using sudo, you should use that command again.

Later on, when you're actively using CocoaPods by installing pods, you will be notified when new versions become available with a CocoaPods X.X.X is now available, please update message.

Using Bundler to manage Ruby dependencies

Bundler is to Ruby what CocoaPods is to iOS. It manages dependencies for a Ruby project.

You can use Bundler to pin the version of CocoaPods you want to use, along with any other Ruby projects you may use such as fastlane or danger.

For more info, see using a Gemfile.

Using a CocoaPods Fork

There are two ways to do this, using a Gemfile (recommended) or using a development build that are in discussion or in implementation stage.

<Using CocoaPods

Head over to Using CocoaPods for details on the usage of CocoaPods.