Podfile.lock 是在第一次運行 pod install 時生成的

屏幕快照 2019-10-30 下午4.56.18.png

屏幕快照 2019-10-30 下午5.00.54.png
Podfile.lock這個文件是用來鎖定版本的,如果沒有指定版本的話,如下面這種寫法
pod 'AFNetworking' (沒有指定版本)
會有兩種情況:
第一、存在Podfile.lock,則根據(jù)該文件的鎖定版本進行
第二、不存在Podfile.lock,則檢索最新版本
(pod install優(yōu)先遵循 Podfile 里指定的版本信息;其次遵循 Podfile.lock 里指定的版本信息來安裝對應的依賴庫)
但是我想在存在Podfile.lock版本被鎖定的情況下進行更新到最新版本,該怎么做?
查看當前遠程庫里是否有發(fā)布新版本
pod outdated --no-repo-update (該命令只針對存在新版本的庫)
shoubindeMacBook-Pro:helloWorld shoubintao$ pod outdated --no-repo-update
Analyzing dependencies
The color indicates what happens when you run `pod update`
<green> - Will be updated to the newest version
<blue> - Will be updated, but not to the newest version because of specified version in Podfile
<red> - Will not be updated because of specified version in Podfile
The following pod updates are available:
- AFNetworking 3.1.0 -> 3.2.1 (latest version 3.2.1)
[!] Automatically assigning platform `iOS` with version `12.2` on target `helloWorld` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
[!] There are duplicate dependencies on `AFNetworking` in `Podfile`:
- AFNetworking
- AFNetworking (~> 3.2.1)
發(fā)現(xiàn)有3.2.1的新版本
pod update --no-repo-update
shoubindeMacBook-Pro:helloWorld shoubintao$ pod update --no-repo-update
Update all pods
Analyzing dependencies
Downloading dependencies
Installing AFNetworking 3.2.1 (was 3.1.0 and source changed to `https://cdn.cocoapods.org/` from `trunk`)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
[!] Automatically assigning platform `iOS` with version `12.2` on target `helloWorld` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
使用pod install 的話會被Podfile.lock文件版本鎖定
但是如果使用pod update可以忽略不理睬Podfile.lock文件,直接更新遠程庫中的最新版本

屏幕快照 2019-10-30 下午5.22.18.png

屏幕快照 2019-10-30 下午5.22.40.png
結果已經(jīng)更新到了最新版本3.2.1