Cocoapods Pod install – Pod update differences

How to get a clear succinct picture of these two popular actions.

Use pod install to install new pods in your project. Even if you already have a Podfile and ran pod install before; so even if you are just adding/removing pods to a project already using CocoaPods.

Use pod update [PODNAME] only when you want to update pods to a newer version.

Now, here’s the tricky part, if there’s an existing Podfile.lock that specifies the versions of all requested pods, there is no difference.

pod update

When you run pod update PODNAME, CocoaPods will try to find an updated version of the pod PODNAME, without taking into account the version listed in Podfile.lock. It will update the pod to the latest version possible (as long as it matches the version restrictions in your Podfile).

If you run pod update with no pod name, CocoaPods will update every pod listed in your Podfile to the latest version possible.

pod install

This is to be used the first time you want to retrieve the pods for the project, but also every time you edit your Podfile to add, update or remove a pod.

Every time the pod install command is run — and downloads and install new pods — it writes the version it has installed, for each pods, in the Podfile.lock file.

This file keeps track of the installed version of each pod and locks those versions.

When you run pod install, it only resolves dependencies for pods that are not already listed in the Podfile.lock.

For pods listed in the Podfile.lock, it downloads the explicit version listed in the Podfile.lock without trying to check if a newer version is available

For pods not listed in the Podfile.lock yet, it searches for the version that matches what is described in the Podfile (like in pod ‘MyPod’, ‘~>1.2’)

In a nutshell, use pod install for installing, re-installing, repairing, re-download, etc. Use pod update for updating the pod you already have to a newer version (if available).

Main source:
https://cocoapods.org

Leave a Reply

Your email address will not be published. Required fields are marked *