Cocoapods, scale your iOS/OS X project easily.
Since the first day of my life developing for iOS, I was introduced to cocoapods.org and I felt in love with it, but, What is Cocoapods?.
Basically, it's both a dependency manager tool and a site to find thousands of libraries -called pods- to scale your project in an easy way. You can find libraries to connect with third party services or image processing, etc.
It is very simple to install Cocoapods in your computer. It's built with Ruby, which is available by default in OS X. The first step is to open a Terminal window and type:
$ sudo gem install cocoapods
The second step is to search in cocoapods.org for the pods you want to use. After doing that, go to your Xcode project folder and create a file named podfile without file extension. The first two lines should look like this:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0'
The second line specifies the platform version we are targeting, so you are free to set it. And after the fourth line, you can add all the pods that you want. For example:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' pod 'Parse', '~> 1.4.2' pod 'JASidePanels', '~> 1.3.2'
I strongly recommend you to write the complete version number of the pods -usually the 3 numbers-. I started to do it since the time I got the older version from a pod and it caused a lot of problems in my project. Now its time to install the pods:
$ pod install
Sometimes, the first time you do this, you probably get this error message: "No such file or directory – /Users/username/.cocoapods/repos (ERROR:ENOENT)".
To fix it, type this command:
$ pod setup
Once you get the pods installed, remember to always open the .xcworkspace instead of .xcodeproj. And finally, import the dependencies:
As I said, I've been using cocoapods since the first day I wrote a line of code for an iOS app. They are very useful, I don't have to reinvent the wheel every time that I need something specific. You can modify the code if you need something extra too, so thank you very much, Open Source!
Thanks for reading! If you have any questions or want to add anything, please use the comment section below.
See you on the next post!