The key to understanding the difference between Pod Install and POD Update is to understand the rationale behind them
What does Pod Install do?
To be clear: I don’t know exactly what was done internally. But experiments and official documentation give an idea
- Pod Install: Installs, removes, or updates pod libraries based on Podfile, podfile. lock, and the pod libraries currently installed (that is, the pod libraries in the Pods directory)
- When install is complete, the installed POD libraries and all directly and indirectly dependent pod libraries are written to podfile.lock
Every iOS developer knows that Pod Install can add and remove pods. However, you can also update the Pod.
I made the same mistake earlier in this section: I didn’t think pod Install could be used for pod library updates
There’s a reason for that,
- Because of the name of the command, the difference between install and update is obvious
- On the other hand, in some cases, it is found that pod Install does not update the pod
The reason for the problem (and the key to understanding pod Install) is that pod Install checks podfile.lock when executed
Pod Install checks podfile.lock when it executes
- Podfile.lock exists to ensure that all team members have access to exactly the same dependent code base
- So when you install, you check both Podfile and podfile.lock for each pod
To recap from the above: In some cases, it is found that pod Install does not update the pod
- Suppose you create A new project and enter library A in your Podfile as
A, pod '1.0'
Run pod Install - Once done, library A in Podfile.lock will be version 1.0. Now let’s change the dependency of A in the Podfile to
pod A
(Assume that the latest version of the current A library is 1.1) pod A
Update A to 1.1, but when pod install is executed, A is still 1.0- When pod install is installed, check to podfile. lock to record the 1.0 version. When pod install is checked to Podfile, check to Podfile to find the 1.0 version can also be satisfied
pod A
, so no updates have been made
Pod Install How to update pod
- Suppose you create A new project and enter library A in your Podfile as
A, pod '1.0'
Run pod Install - Once done, library A in Podfile.lock will be version 1.0. Now let’s change the dependency of A in the Podfile to
Pod A, 1.1
(Assume that the latest version of the current A library is 1.1) - When pod install is implemented, it is found that version A has been updated to 1.1
- When pod install is installed, check to podfile. lock to record the 1.0 version. When pod install is checked to Podfile, check to Podfile to find the 1.0 version cannot be satisfied
Pod A, 1.1
, so download version 1.1 of A
If pod install can update a POD, is a POD update necessary?
B: of course!
The POD Update does this: Unconcerned about the contents of podfile. lock, updates the pod according to the one specified after pod update (or all pods in Podfile if not specified), combined with the version information in the Podfile, and writes the update result to podfile. lock
The reason is:
- Pod install is for the entire project of all libraries to add, delete, change; Sometimes we just want to update a library, and pod update is more convenient
- In the previous section, we mentioned a situation where using Pod Install might not be able to achieve the desired pod update
reference
- pod install vs. pod update