Cocoa Pods is an Objective C library manager that manages library dependencies for your Xcode project
Yes, remember when we tried to add AFNetworking to our project or core plot…. It was a procedure of certain steps. Now, with Cocoa Pods is one and only step!
Cocoa Pods came to make our life easier.
Cocoa Pods is an Objective C library manager that manages library dependencies for your Xcode project. The goals are:
Make working with dependencies simple. Improve library discoverability and engagement by providing an ecosystem that facilitates this So using Libraries would be just a game.
Let’s start with Pods now.
Xcode includes a “Downloads” preference pane to install optional components. Open this pane by clicking the “Xcode” button in the top left of the screen, then click “Preferences”, then click “Downloads”. Choose Components Tab and click the install button of the Command Line Tools.
Open your terminal and type:
sudo gem update --system
sudo gem install cocoapods
Now, go to your Xcode project directory and create a text file named Podfile. A Podfile is the file that lists the dependencies of your application, which is usually located in the root of your project.
Navigate to the folder using the appropriate commands on your terminal and then type:
touch Podfile open -e Podfile
If everything is ok, TextEdit will open to an empty text file. Type inside TextEdit for example:
platform :ios pod 'JSONKit', pod 'AFNetworking', '1.0'
With this Podfile you will add to your project JSONKit (the most recent version) and AFNetworking version 1.0. At the beginning you define your platform (you can define osx as well). More about Podfiles you can find here.
Let’s get back to our example. Save and Close TextEdit. In your terminal type:
If the procedure ended without error we are ready. Open your project folder and you will discover a new file. This is
This is the workspace where CocoaPods stores all the libraries dependencies. From now on, you will use only this workspace.
That’s it. If you need an additional library just add the appropriate line to your Podfile (use the CocoaPods site to find all the available pods), save it and type in your terminal:
For a more detailed guide, please read Marcelo’s Fabri great tutorial “Introduction to CocoaPods“