When I started developing in Xcode for the first time I never felt there were real needs for installing CocoaPods in my computer. Although many people recommended installing it I just thought it was easier copying and pasting/adding the whole source into my projects, but then after working with many third party libraries I decided to give it a try.
What I really liked was that adding libraries was much easier than expected, it allows to target specific iOS firmwares and nonetheless to download a specific version with a couple lines.
Here are the steps:
1.- In Xcode, create a single view application (iOS) and close the project.
2.- Open the terminal and enter the following lines:$sudo gem install cocoapods (be sure to have a fast internet connection, otherwise it will throw errors)
3.- After it is done add the following line:
$pod podsetup (might take few mins)
4.- After it has finished, you can retrieve the whole list of libraries (there are few thousands, not recommended) or you can search by title, or parts of letters as shown below
$pod search MMD
5.- Now, we need to do 2 things, copy the fill line of the version of the library we want. For this example, I am just copying this line “pod ‘MMDrawerController’, ‘~> 0.5.2′” without the double quotations. We need this for our Podfile that we will be creating now to let know CocoaPods from the Podfile which library we want. CocoaPods will go into our poject folder, read the Podfile and get the library specified in the Podfile, that is why I just copied the line I copied (sorry for being redundant).
6.- Now in the terminal go to your projects folder (cd ProjectDirectory/) and type the following
6.1 $vim Podfile6.2 Hit key ‘i’ so that you are allowed to insert and paste the line you just copied in the clipboard. After that hit escape and type ‘:wq’ (write&quit) after exiting, the terminal should look like this:
7 now just enter $pod install and the terminal should look like this:
8.- Open your Xcode project with the ‘xcworkspace’ file and library should be installed
Pretty straight forward 🙂