What is Cocoapods? What is Cocoapods? xcode xcode

What is Cocoapods?


"CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 30 thousand libraries and is used in over 1.9 million apps. CocoaPods can help you scale your projects elegantly." via http://cocoapods.org

Essentially, it helps you incorporate 3rd party libraries, frameworks, into your product without worrying about how to set them up and configure your project, which at times could be a huge pain.

Regarding why can't you just include files in your project?

  • Since these are 3rd party so you will have to download and copy them to your project every time there is a new version? Lets say, you have 10 libs or frameworks in your project, now imagine the time it will take you to check if anyone of them has any new version that you want to update? and Worst if something does not work, you need to revert back to previous version? It does take time and is a nuisance, with CocoaPods you simply type pod update and updates the ones that have newer versions available.

  • Now If you want v1.1 of one particular library? How easy would it be for you to skim through Git commit history to find out which one you need? With CocoaPods, you simply say pod 'AFrameworkLib', '1.1'

  • Every lib requires setting up your project with a certain set of configuration to make them work, doing it for 10 or so libraries and then fixing conflicts is pain in itself. With CocoaPods, its taken care of automatically.

  • Last but not least, you have to include licenses for all 3rd party libraries you are using to provide credit to original developer of that library. Imagine copying 10 license docs and making sure they are up to date? CocoaPod automatically creates an acknowledgement file in your project that you can simply include somewhere appropriate.


From https://cocoapods.org:

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.

Project link: link

Specs (third-party tools):link

Getting started guide: link


CocoaPods is a dependency management tool for objective-C projects similar to what Maven's for Java projects, which is written in Ruby and is made of several Ruby Gems. The idea is that once you add the third party libraries to your project you'll no longer need to check if there's any newer versions. CocoaPods will handle that for you. It also makes reversing back to a certain version of the library super easy. To use it, follow the following steps. More detail can be found on the official web site at http://cocoapods.org

  1. Run the following command on your mac

sudo gem install cocoapods

  1. Search cocoapods.org for your desired libraries, then create a text file called Podfile in your Xcode project directory, with entries like

   source 'https://github.com/CocoaPods/Specs.git'   platform :ios, '8.0'   pod 'AFNetworking'   pod 'ARAnalytics', '~> 2.7'

For each library you can optionally specify a minimum version.

  1. Then you run these commands to initiate all necessary components in your project directory
pod setuppod installopen YourApp.xcworkspace

Now your project is ready to go. Note the last command in the above is opening YourApp.xcworkspace, not YourApp.xcodeproj, otherwise you'll get "library not found -lPods" error when building your app.