Why Do We Need CocoaPods?

mainLinker errors are painful to deal with. When we are working on our Xcode projects and when we almost done with everything, these linker errors pop up to make their point! Even if we can see the libraries right there in the GUI, it still can’t find that library. Sounds familiar? Why do we have to set linker flags in more places? Wouldn’t it be easier if you could just start developing your project without having to worry about these things? Say hello to CocoaPods! CocoaPods is a library dependency manager for Objective-C projects that solves all these issues. CocoaPods is a ruby gem that downloads all the third party libraries you want for your project, and links everything so that you don’t have to.  

To install it, just execute the following commands from your terminal:

>> sudo gem install cocoapods
>> pod setup

You just need to create a simple file, called a Podfile, and list the libraries you want. You can also optionally specify a version for each library. That’s it! You now have CocoaPods installed on your machine.

Now you can go into your Xcode project and run the following command from your terminal to install all the library dependencies:

>> pod install

Rather than work in an Xcode project, CocoaPods builds an Xcode workspace for you to work in. A workspace is nothing more than a collection of projects, and CocoaPods takes advantage of this by creating it’s own project which includes all the downloaded libraries, and linking the Pods project with your project. It’s easy to setup and doesn’t intrude in your work. It’s pretty simple to modify as well if you need to add or remove libraries later. Once you start using CocoaPods, you wouldn’t want to go back to managing library dependencies yourself.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s