Monday, March 17, 2014

CocoaPods what is it?

Happend to know about CocoaPods recently and thought to do some investigation around it. Below are my few notes about what is it and how does it work.

CocoaPods as it is advertised is a best (?) tool to manage library dependancies in Objective C projects. Instead of copying some code from Github and updating the project with the latest version etc, CocoaPods will do this for a developer.

CocoaPods runs on Ruby and that is the only dependancy one need for making the CocoaPods up and running.  This makes it lot more easier because all versions of MacOS ships with Ruby. The only task needed is to update to RubyGems. To do, so below command can be entered in Terminal.

sudo gem update --system


To have the dependency created, below commands can be given in the pod file

platform : ios
pod: 'AFNetworking', '0.9.1'

The above installs the dependency AFNetworking classes with version 0.9.1

To install the dependancies, the below command needs to be given

pod install

Once after the dependancies are downloaded, it will generate a workspace and from then on use the workspace instead of the project file.

Below example downlaods the Nimbus dependancy first and then installs the NSAttributedLabel classes

pod Nimbus/NSAttributesLabel

This is a good tool infact. Below given is what is happening behind the scenes

- Creates or updates a workspace
- Adds one's project into workspace if needed
- Adds Cocopods static library into project space
- Adds cocopods static library to the project
- Adds Cocoapods xcode configuration file to the project
- Changes app's target configurations to be based on Cocoapods
- Adds a build phase to copy resources from any pods you installed in your app bundle.

Anyway, this is cool. This triggers me to think to do some custom script file that is based on Ruby to write soemthing for my project anyway!!

References:
http://guides.cocoapods.org/using/using-cocoapods.html
http://www.raywenderlich.com/12139/introduction-to-cocoapods

No comments:

Post a Comment