🥥CocoaPods
Fall 2023 | Vin Bui
What is CocoaPods?
CocoaPods is a dependency manager for Swift and Objective-C projects in Xcode. It is used in over 3 million apps and contains over 95 thousand libraries. It is similar to pip for Python and npm for NodeJS. In other words, you can use code written by other people in your own Xcode project to make your life easier!
CocoaPods Setup
To install CocoaPods, simply run the following in the command line:
sudo gem install cocoapodsNavigate to your Xcode project directory and run this command:
pod init. This creates aPodfilein your directory.Open the
Podfileand list out the pods you want to install. For example, if I wanted to install the latest version of SnapKit and Alamofire, myPodfilewould look something like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
use_frameworks!
# Pods for MyApp
pod 'SnapKit'
pod 'Alamofire'
endChange ‘MyApp’ to the name of your project.
Once you are done, save your
Podfileand install the dependencies by runningpod installIf this command does not work, try
pod install --repo-update
You must open the Xcode workspace instead of the project when using CocoaPods!
Last updated
Was this helpful?