What are CocoaPods? 

And why use them.

Posted by sbastidasr on July 9, 2015

When I started on iOS development, nobody told me to use CocoaPods, and that it the reason why I am writing this post. If you use them, great. If not, hang in there. Here is my reason for using them.

CocoaPods is the dependency manager for Swift and Objective-C Cocoa projects. It has almost ten thousand libraries and can help you scale your projects elegantly.

So, what is a dependency manager?  It is a program that standardizes the way you use libraries. And, if you’ve added libraries on Xcode, you know the meaning of true pain. This is the compiler screen that precedes a million compiler errors.

Post Sample Image

Now, what if you are developing with a team. Usually, projects use certain versions of libraries. All developers would have to specify, download and install the exact version of the needed library. An update may break other’s build and so on. The Podfile standardizes this. Add it to your git and done. Everything is handled for you.

Adding/Deleting dependencies becomes as simple as adding them to the Podfile and installing. Dependencies between libraries are automatically handled.

Post Sample Image Sigh, errors.

Especially, if you are using libraries like Parse on your apps: you will get about a 100 of these if you add more dependencies: Post Sample Image StackOverflow Question

So… removing flags actually fixes the problem but maybe some other libraries need those flags.

How to solve this using CocoaPods

Install CocoaPods on your machine

$ sudo gem update –system
$ sudo gem install cocoapods
$ pod setup

Initialize Pods on your Project

cd into your projectfolder: cd ~/cool/app/Folder/
pod init
open -a Xcode Podfile

Write this on your file, with the pods you want to add. In this case WYPopover from git and Parse.

platform :ios, ‘6.0’
pod 'WYPopoverController’, :git =>
'https://github.com/nicolaschengdev/WYPopoverController.git’ pod 'Facebook-iOS-SDK’
pod 'Parse’
pod 'ParseFacebookUtils’

Open your terminal once again and

pod install

It will tell you to use the workspace and not the project from now on.