Using CocoaPods FTW
I can’t tell you the number of hours I would have saved if I started using CocoaPods earlier!
If you are developing with XCode you might already know that linking libraries to your project is a major pain… Fear no more! CocoaPods is here to save your time and day.
There are lots of resources on how to install and use CocoaPods, so here is yet another one created by me:
Using the terminal do the following steps:
1. Update the ‘gem’
sudo gem update --system
2. Install CocoaPods
sudo gem install cocoapods -V
3. Setup CocoaPods
4. Add a Podfile to your project
- Using the terminal, cd to your project directory (the one with the .xcodeproj file in it)
- Run these commands to create a Podile file:
touch Podile edit Podfile
5. Add the libraries you want to install to the file
For example to add MWPhotoBrowser version 1.0.1 to an iOS project write the following lines inside the Podfile:
platform :ios pod 'MWPhotoBrowser', '1.0.1'
Save and close the file when done.
6. Install Pods!
Once you have all your libraries defined inside the Podfile, install all dependencies with the command: (remember: from the project directory!)
7. Build and Enjoy!
When all of the pods finish installing, you will notice a .xcworkspace file. You will need to open this file with XCode from now on to use your libraries with your existing project. A workspace is needed to put together several libraries with your project. Easy hugh?