Thursday, December 25, 2014


Introduction to CocoaPods 

WHAT IS COCOAPODS ?

CocoaPods is “the best way to manage library dependencies in Objective-C projects.” It has thousands of libraries and can help you scale your projects elegantly. CocoaPods is a reflection on the Cocoa community, a mirror that reflects the effort of thousands on individual contributions to a greater idea of sharing and helping each other to improve. 

You specify the dependencies for your project in one easy text file named "Podfile" in Your Project Folder. CocoaPods resolves dependencies between libraries, fetches source code for the dependencies, and creates and maintains an Xcode workspace to build your project. Ultimately, the goal is to improve discoverability of, and engagement in, third party open-source libraries, by creating a more centralized ecosystem. Installing and updating CocoaPods is very easy. 

Instead of downloading code from GitHub and copying it into your project (and thus making future updates difficult), you can let CocoaPods do it for you.

How to Implement & Use Podfile in Project ?


To get started, you first need to install CocoaPods. CocoaPods runs on Ruby.

To do so, open Terminal and type the following command:

sudo gem update --system

Enter your password when requested. The Terminal output should look something like this:


Next, you need to install CocoaPods. Type this command in Terminal to do so:

sudo gem install cocoapods


Lastly, enter this command in Terminal to complete the setup of CocoaPods:

pod setup



Check & Set Directory in terminal Like this :

cd /Users/mac-mini/Downloads/DemoApp
pod init
open -a Xcode Podfile

You can see in Project File  ->>>






after that, Open Pod File. you have to add library name & Version OR Library name in PodFile.
Example,

# platform :ios, ‘7.0’
target 'DemoApp’ dopod 'MBProgressHUD'pod 'Reachability'end
target 'DemoAppTests' do
end





After Completing these Save The File .
Back to Terminal & Write :

pod install



& done.


Then after Close Xcode & open DemoApp.xcworkspace always

Note:- To use Pod library files always do not open DemoApp.xcworkspace but always open BlurDemo.xcworkspace & open project & then import files in ViewConroller.m & Enjoy Coding.

If you want to Update Pod Use below Commant :

pod update

So, Revise all. From Beginning Finally you have to Write Below Code :

sudo gem update --systemsudo gem install cocoapodspod setupcd /Users/mac-mini/Downloads/DemoApp   //Change Directory to your Project Filepod initopen -a Xcode Podfile

//& Add Library Pod Name like , 
pod 'MBProgressHUD'pod 'Reachability'

& save PodFile .

Then 
pod install



& open Xcode Project File -> DemoApp.xcworkspace & Import Library into ViewController .

You can also Search Pod file of any Library like :

pod search sdwebimage


If you wan to Update the Pod then Simple use:

pod update

& if u want to remove any Library then just remove it PodFile  & save & the Update it. 
It will successfully Remove from your Project.

Enjoy Coding.

After Using Pod , you do not need to download Library file & Add files to Project.
Pod file Automatically download Latest Version Of Library From Github.




No comments:

Post a Comment