CocoaPods is a way to manage library dependencies in Xcode Project.
Installation of CocoaPods.
CocoaPods runs on Ruby and that's only dependency it has. All recent version of Mac OS X(Since OS X 10.7) ship with Ruby already installed. So only need to update RubyGems.
To Update RubyGems open Terminal and type following command:
sudo gem update --system
Enter password when requested.
This update may take little while, so give few times to complete.
Next, install CocoaPods using following command:
sudo gem install cocoapods
if get below prompt during installation process:
rake's execute "rake" conflicts with /user/bin/rake
Overwrite the executable? [y/n]
just enter y to continue.
Now, type the command to complete the process of CocoaPods installation:
pod setup
Done, now we are ready to use CocoaPods.
Installation of dependency within the Project using CocoaPods
use Terminal and navigate to Project directory
cd ~/.. /.. /Project Name
Now, type following command to create Podfile for Project.
pod init
Type command to open Podfile
open -a Xcode Podfile
Default Podfile should look like this
command for add dependencies:
add 'LibraryName', 'Version'
For ex. going to download AFNetworking
pod 'AFNetworking', '2.2.1'(add just below target 'ProjectNmae' do line)
This tell CocoaPods that you want to install AFNetworking version 2.2.1.
Save and close Podfile.
Now, go to Terminal and type following command for download dependency.
pod install
After completion of download you can see a message
From now on use 'ProjectName.xcworkspace'.
Go to Project directory and open "ProjectName.xcworkspace".
For more information Click here
Installation of CocoaPods.
CocoaPods runs on Ruby and that's only dependency it has. All recent version of Mac OS X(Since OS X 10.7) ship with Ruby already installed. So only need to update RubyGems.
To Update RubyGems open Terminal and type following command:
sudo gem update --system
Enter password when requested.
This update may take little while, so give few times to complete.
Next, install CocoaPods using following command:
sudo gem install cocoapods
if get below prompt during installation process:
rake's execute "rake" conflicts with /user/bin/rake
Overwrite the executable? [y/n]
just enter y to continue.
Now, type the command to complete the process of CocoaPods installation:
pod setup
Done, now we are ready to use CocoaPods.
Installation of dependency within the Project using CocoaPods
use Terminal and navigate to Project directory
cd ~/.. /.. /Project Name
Now, type following command to create Podfile for Project.
pod init
Type command to open Podfile
open -a Xcode Podfile
Default Podfile should look like this
command for add dependencies:
add 'LibraryName', 'Version'
For ex. going to download AFNetworking
pod 'AFNetworking', '2.2.1'(add just below target 'ProjectNmae' do line)
This tell CocoaPods that you want to install AFNetworking version 2.2.1.
Save and close Podfile.
Now, go to Terminal and type following command for download dependency.
pod install
After completion of download you can see a message
From now on use 'ProjectName.xcworkspace'.
Go to Project directory and open "ProjectName.xcworkspace".
For more information Click here

No comments:
Post a Comment