CocoaPods is the dependency manager for the projects. It has number of libraries and can help you scale your projects easily. CocoaPods is built with Ruby and is installable with the default Ruby available on your mac machine. The main advantage of Cocoapods is that the libraries are hosted on other machine and you can easily integrate to your project by simply modifying the pod file and hit one command to install/update the pods (you can refer them to as your libraries or frameworks). Below are the steps to install Cocoapods and use them with your project
** Make sure you have installed/updated command line tool in your Mac machine. You can check this by opening Xcode, navigating the menu to Xcode > Preferences > Downloads > Components, finding Command Line Tools and select install/update.
If you see command line tools then install those first. If they are installed then please proceed further. Open terminal and execute below commands
sudo gem install -n /usr/local/bin cocoapods
|Executing sudo gem install cocoapods in the terminal|
|CocoaPod installed successfully|
2) Set up pods with your Xcode project. Open terminal and type the change directory command
cd path of your XCode project root directory (where your ProjectName.xcodeproj file is placed)
write your libraries name as show below. Save and close text editor.
NOTE: Use ( control + ” ) button to add single quote at both end of library name. It should be shown as straight vertical line. Without control button it shall be added as curly single quote which will give error while installation of file.
$ pod install - install all the libraries written in the pod file
After successful downloading/installation of any single library, It will generate ProjectName.xcworkspace in your project root directory. From now use this workspace to open your project. When you open your project work space you will see Pod is also added as another Xcode project with your Xcode project. If you open Pod it will show all libraries.