pod install vs. pod update

什么时候使用 pod install 和 pod update命令.

引用podGuide,意思是说在一下2种场景下使用install 命令:

  1. 在工程中第一次引入pods的时候,这时候我们创建Podfile添加需要的pod Item. 在执行安装这些pod Item的时候. 也就是说第一次刚用的时候! 这一点, 和我们大家想的都一样. 无可非议, 第一次使用嘛,肯定要安装了.
  2. 尽管我们工程中已经含有Podfile了,之前也已经运行过install命令, 但是这时, 我们修改了Podfile(增加/删除 pod Item). 我们也应该使用install 命令. 不要惊讶! 之后,会详细介绍install命令执行的细节.

至于update 命令:
只有当我们需要更新一个pod Item 到一个newer版本的时候, 才需要使用 pod update [PODNAME] 命令.

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

如果不指定PODNAME,默认更新所有pod Item 至最新版本.

pod install底层做了什么?
当我们项目引入了cocoapods 作为依赖管理工具的时候, 在当前项目目录下可以看到两个重要文件,一个是Podfile,另外一个是Podfile.lock 顾名思义,第二个的作用肯定是为了锁住第一个Podfile.
弄清楚这两个文件的作用,就知道install到底做了什么事情了.
Podfile.lock是我们已经安装好了的pod Item的清单. 并追踪了清单内每个pod item的版本等信息. Podfile使我们将要安装的清单.

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

当我们使用pod install的时候, 首先检查,Podfile内将要安装的Item 是否已经安装,<通过检查Podfile.lock文件>,如果已经安装,并且版本也一样. 那么什么也不做,如果没安装或者版本不一样. 那么就安好Podfile列出的条目安装,并且记录在Podfile.lock内.

你可能感兴趣的:(pod install vs. pod update)