This guide serves as a quick glance at the most common commands an end user might use when managing their package dependencies in CocoaPods.
There are quite a lot of different nuanced features in the tool, which you may not need. Ultimately, the source of truth when using CocoaPods is the official documentation, which describes every feature available.
Basic commands
You’ll only need to do this once per project, but if you don’t already have a Podfile
and corresponding .xcworkspace
file, running this command will set that up for you:
pod init
Once you have an existing Podfile
, this command will install the necessary dependencies described in it. Running this for the first time will generate a Podfile.lock
.
pod install
A note about the Podfile
and Podfile.lock
- Your
Podfile
contains the list of dependencies that you define for your project. You can set version constraints to ensure that you only receive versions within your defined range. - Your
Podfile.lock
is automatically generated after installing your pods. Future versions ofpod install
will adhere to the version constraints in the.lock
file.
Separate from the install
command, the update
command will update all packages to the highest version available (provided there are no ceiling constraints defined in your Podfile). Doing so will override what’s constrained the Podfile.lock
:
pod update
Calling update
on a specific package will update only that package to the latest available version as well as any of its own implicit dependencies:
pod update {specific-package}
Common troubleshooting commands
If you’re certain that there’s a new version of a pod available, but you’re getting an error that there’s no such version, you can try running this command to update your local pod references:
pod repo update
Sometimes, your project may have weird issue cached from a previous CocoaPods install. To completely reset the installed packages, you can run this command and then subsquently re-run pod install
:
pod deintegrate
Managing different versions of the CocoaPods tool
Say you have multiple versions of CocoaPods installed on your machine and want to use a specific version, you can use the following syntax:
pod _1.12.3_ install
pod _1.12.3_ update
One final note
I’ve also made this document available as a GitHub gist here.
In the past, I have given a talk on the ins and outs of using CocoaPods. If you’d like to reference some of those details, the deck is available here.
Top comments (0)