How to add Pods into Xcode project?

Screen Shot 2017-02-06 at 11.49.05

Reading book is good practice, but it’s time to write several mini-tutorials on various problems, that I meet constantly. Today we will think about how to add Pods into your Xcode project.

CocaoPods (full name of “Pods”) is library manager for Xcode projects.

Lots of obj c and swift libraries can be installed using CocaoPods. It is very easy way of adding new library and it is definitely more accurate than copy-pasting source code of library. Lets see step by step how to add new Pod into your Xcode project.

Step 1

Create your Xcode project (File -> New -> Project). I chose “Single View Application”.

Screen Shot 2017-02-06 at 13.07.45

Step 2

For example I want to add ImagePicker library. In main page of this library’s GitHub page I found that the name of Pod is “ImagePicker”.

Screen Shot 2017-02-06 at 13.15.42

Step 3

Check whether CocoaPods installed on your computer. Run command on terminal:

pod --help

If you see instructions of using pod command (like on screenshot below), CocoaPods is installed.

Screen Shot 2017-02-06 at 13.22.48

Otherwise you need to install it using command:

gem install cocoapods

Maybe you will be forced to use “sudo”: sudo gem install cocoapods.

Step 4

CocaPods installed. The next task is to prepare Podfile.

platform :ios, '10.0'
target 'InstallPodProject' do
    pod 'ImagePicker'

Screen Shot 2017-02-06 at 13.32.27

Save this file as “Podfile” in root folder of your Xcode project. Replace “InstallPodProject” with the name of your project.

Step 5

It’s time to install Pod. Type in terminal:

pod install

You should see message of successful installing like this:

Screen Shot 2017-02-06 at 13.35.39

.xcworkspace file will be generated.

Step 6

Use this library in project. Before doing this remember that you need to open .xcworkspace file, not .xcodeproj. In Xcode check that in Pods you have desired library.

Screen Shot 2017-02-06 at 13.38.23

Build project (Cmd+R) to compile Pods. Import library in class you need and use this library.

Screen Shot 2017-02-06 at 13.41.05


If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Profile photo of Doszhan Kalibek

Doszhan Kalibek