×

CocoaPods


What is Cocoapods ?

CocoaPods is used for installing or updating third-party SDKs while working with XCode. Suppose you want to integrate Google Sign-in within your app. Then you have to install google SDKs. So CocoaPods provides an easy way to install Google SDKs. Similarly, you can install any third party library with the help of CocoaPods.

How to install CocoaPods ?

You can install CocoaPods tool on OSX by running the following command in terminal

sudo gem install cocoapods

How to use Cocoapods to install any third party SDK in iOS App ?

Suppose you want to add Google SDK in your iOS app . Follow the steps :-

1) Create an Xcode project, and save it . In my case , I saved the project on Desktop.

2) Create a file named Podfile in your project . This file includes all the dependencies which you want to install.

(File > New > File > Scroll Down to Others Category > Empty > Next > Save As > Podfile > Create)

3) Now open Podfile and add your dependencies .

platform :ios, '9.0'

target 'CodzifyProject' do
use_frameworks!

pod 'GoogleSignIn'

end

CodzifyProject is the name of my project . You must replace it it with yours. pod 'GoogleSignIn' is the Google Sign-in SDk which I took as an example to install.

4) Save the file.

5) Open a terminal and cd to the directory containing the Podfile. In my case , project is saved on Desktop.

cd Desktop
cd CodzifyProject
// Here 
CodzifyProject is the name of my sample app.

Now CodzifyProject is the directory which contains Podfile. You can check using ls command.

ls

6) Run pod install command to install the dependencies.

7) Close Xcode . Close terminal . Now you can see .workspace file of your project is being created. In my case , its CodzifyProject.workspace. Open it and from now onwards use this .workspace file .

In this way you can install any SDK you want using CocoaPods. Just integrate the name of dependency in Podfile and perform the given steps. You can use this link for more information on Google Developers page .