Cocoapods: How Did I Stop Worrying And Used It
Three years ago, iOS developers created a web project that was very ambitious.. It was called (cocoacontrols.com).
The idea was simple: developers will find controllers that other developers submit there. Controllers that could solve a lot of day to day issues. The idea was just like Rails Gems. No one thought this site could stay any longer than a year or so, a site that require the developer to submit their code to share it with everyone else. What is that? But it's the open source world, yes it's possible. And the site went wild, the problem still was: developers could spend like an hour or so applying a simi-complex controller. That was when Eloy Durán came.
The Rise Of Cocoapods
When Eloy Durán made the website cocoapods.com, I was very happy. At last my problems will be gone. At last Rails developers will not tease us anymore with how much Gem deploying is a piece of cake. Cocoapods have the same effect on iOS that Rails have when they changed from plugins to gems.
How Can We Do It?
It's simple, as I said, just like Rails framework. You might need to run the following command first:
$ sudo gem install cocoapods
NOTE: yes I know .. you maybe still using macOSX prior to Mavericks .. that means you'll face a lot of troubles .. Mavericks users.. you are ok.. you just may need to give full permissions to some files using following command
$ sudo chown -R YOURUSERNAME /Users/YOURUSERNAME/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/cocoapods-0.28.0/
After that you can get the controller you want let's say EZAudio you'll find there a line like this
pod 'EZAudio', '~> 0.0.1'That's all you need.
Now, fire up your Terminal and do the following:
$ cd PATH_TO_YOUR_iOS_PROJECT $ vim Podfile
Edit the file file as following:
platform :ios pod 'EZAudio', '~> 0.0.1'
Now, you can install the dependencies in your project:
$ pod install
Open the project from now on from YOURAPPNAME.xcworkspace file.
Voila! Now you can add whatever the controller requires. What cocoapods made is put the frameworks that the controller needs and any images or resources that is required.
Create A Pod
What if you made some great code and you felt that others may like to use it. All you need to do is:
$ pod spec create Peanut $ edit Peanut.podspec $ pod spec lint Peanut.podspec
We really love contributions and will help ensure it's perfect!