First you have to understand what the Podfile.lock
is then understand what the Manifest.lock
is and where it's used.
The Podfile
holds either the (optimistic or exact) versions of every dependency you have. The lock file holds only exact versions.
Once you do pod install
all the pods get downloaded/installed into the /pods
directory. You may want to commit them Or maybe not. That's up to your team. What's NOT up to your team is decide if they should commit the the Podfile.lock
or not. That needs to be committed so every dev in the team can be sure they've got the exact same version.
- So let's say you downloaded your team’s code. In your project's root directory you only have
Podfile
and Podfile.lock
and the Pods
directory wasn’t committed.
- Then you do
pod install
to creat the Pods
directory. Your snapshot of every pods’ version should match with the versions of all pods from the Podfile.lock.
- CocoaPods has a safety check in place, to ensure matching versions
This is where the Manifest.lock
comes into play. Manifest.lock
is your local machine's lock created. It has to match with Podfile.lock
that is generated by the last commit (that caused changes in for your pods) in your repo. If it doesn't match then something is messed up.
Docs on what the Manifest.lock file is:
# Manifest.lock: A file contained in the Pods folder that keeps track of
# the pods installed in the local machine. This files is used once the
# exact versions of the Pods has been computed to detect if that version
# is already installed. This file is not intended to be kept under source
# control and is a copy of the Podfile.lock.
I honestly can only think of one scenario in which the Manifest.lock
and Podfile.lock
would be out of sync:
I mean if you pull from main branch, then you get main's Podfile
and lock file. If you then make a change to the Podfile
and then run pod install
, then you would be updating the Podfile.lock
and Manifest.lock
and will keep them in sync. No issues with this
Is this just so that if:
- You and your team don’t commit the
/Pods
directory
- You have merge conflicts in your
Podfile
or Podfile.lock
but don’t realize it. Or you haven't committed both Podfile
and Podfile.lock
- Then given that Xcode doesn’t process the
Podfile
and Podfile.lock
, then naturally your project can build successfully.
- However if you go in an inspect your Build Phases of your targets you'd see the following
That script is documented here
# Adds a shell script build phase responsible for checking if the Pods
# locked in the Pods/Manifest.lock file are in sync with the Pods defined
# in the Podfile.lock.
#
# @note The build phase is appended to the front because to fail fast.
#
# @return [void]
What those lines do are: perform a diff
and ensure that sure your Manifest.lock
i.e. your local snapshot of all installed pod versions are equal to Podfile.lock
i.e. your repo's current snapshot of all installed pod versions.
The fix is likely super simple, just make sure you Podfile
is what you want. Then just run pod install
. You have also somehow accidentally made changes to your Manifest.lock
inside your /Pods
directory (or as mentioned earlier maybe only committed the lock file but not the Podfile
or vice versa). Deleting /Pods
directory causes no harm. Just do a pod install
after. Do not do pod update
unless that's what you want.
Just make sure you never delete the Podfile.lock
otherwise if you do pod install
then it would update all dependencies to the latest version it can.
Also helpful to see and this video on lock files, CocoaPods docs on how the lock file is put to use differently for pod install vs. pod update and last see how all that logic is used in more detail
this artsy blog on checksums. It's worth noting that a single space will create a new checksum and can make things out of sync.
Run 'pod install' or update your CocoaPods installation.
as suggested by the error?Podfile.lock
and inPods/Manifest.lock
? That error occurs when these are not the same.