CocoaPods manages library dependencies for your Xcode projects. https://cocoapods.org/ It’s one of the largest dependencies providers to millions of iOS developers worldwide.
There are 2 ways to install CocoaPods :
- Mac App: download from https://cocoapods.org/app mac app and start it
- Manually: Manual installation is well documented and simple enough to use. https://guides.cocoapods.org/using/getting-started.html#getting-started
However, there are certain more steps that you need to perform to get it working. This post will help you in understandig those steps.
- Open a terminal
- navigate to project folder(containing projectname.xcodeproj).
- enter command pod init
- this will create a Podfile in your project folder.
- do not open the Podfile in the terminal.
- open Podfile in the Xcode using command open -a Xcode Podfile.
- go to https://cocoapods.org/.
- Search for the dependency e.g Alamofire.
- Expand Alamofire
- Click on the button “Installation Guide” located on right side(Scroll down a bit).
- Copy and paste pod ‘Alamofire’, ‘~> 4.5’ into your Podfile
- target ‘MyApp’ do
- pod ‘Alamofire’, ‘~> 4.5’
- save it.
- go back to your terminal.
- type command pod install and press enter.
- It will add the dependency.
- Now open finder go to your project folder and open ProjectName.xcworkspace
- Don’t open the project from Xcode it will by default open .xcodeproj.
- And you won’t be able to resolve the module you imported in that.
- After you open the project.
- Before importing the module build the project.
- after the build succeeds feel free to use it.