How to: Setup CocoaPods in Xcode

Hey, guess what? I’m learning iOS development and have been for months! Thought I might increase my rate of publishing to my blog if I did what I did for my VR course and posted study related stuff here. So to that end…

Here’s a simple step by step guide for adding CocoaPods to your iOS projects. There are quite a few steps involved and I suspect this is something that is done relatively infrequently in a single project. It’s always nice to have a reference for this sort of thing.

Steps

  1. Inside Terminal, change directory to the folder containing the Xcode project
  2. Initialise a new Podfile. You do this by using the “pod init” command. If you need more details read about it in the CocoaPod’s guide for pod init
  3. Open the Podfile in Xcode. Just drag it to the Xcode icon in the dock
  4. Add the library to the pod file. Here’s an example Podfile with SwiftyJSON and Alamofire libraries added
  5. Install the pods using the “pod install” command in Terminal. Here are more details on pod install should you need them
  6. Now open your Xcode project via the new .xcworkspace file

Easy as pie.