最近長時間沒有用自己的電腦進行項目開發(fā),在使用pod install更新項目三方庫的時候,發(fā)現(xiàn)pod版本過低需要更新,在更新Cocoapods遇到的問題。
首先是使用:
$ gem install cocoapods
命令報錯:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
說是沒有權限,那我就加上權限,然后使用:
$ sudo gem install cocoapods
命令依然報錯:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
接著我又換了另外一個命令:
$ sudo gem install -n /user/local/bin cocoapods
還是報一樣的錯誤
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
最后找到一個一發(fā)入魂的命令:
$ gem install cocoapods --user-install
更新成功
Installing ri documentation for cocoapods-core-1.12.1
Parsing documentation for cocoapods-1.12.1
Installing ri documentation for cocoapods-1.12.1
Done installing documentation for rexml, nanaimo, colored2, claide, atomos, xcodeproj, ruby-macho, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, ffi, ethon, typhoeus, public_suffix, fuzzy_match, concurrent-ruby, json, httpclient, algoliasearch, addressable, zeitwerk, tzinfo, minitest, i18n, activesupport, cocoapods-core, cocoapods after 55 seconds
36 gems installed
更新成功后,再次執(zhí)行命令:
$ pod install
報錯如下:(真是一步一坑啊)
[!] CocoaPods could not find compatible versions for pod "AlipaySDK-iOS":
In snapshot (Podfile.lock):
AlipaySDK-iOS (= 15.8.11)
In Podfile:
AlipaySDK-iOS
None of your spec sources contain a spec satisfying the dependencies: `AlipaySDK-iOS, AlipaySDK-iOS (= 15.8.11)`.
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
這個報錯,是說明依賴源版本老舊,一些新版本的三方SDK找不到,需要跟新依賴源,同時也給出了可用的兩個命令,任選其一:
$ pod repo update
$ pod install --repo-update
執(zhí)行命令后可能會遇到一下錯誤:
error: RPC failed; curl 28 Recv failure: Operation timed out
fatal: expected 'acknowledgments'
[!] CocoaPods was not able to update the `cocoapods` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
有可能是網(wǎng)速造成的錯誤:可以多執(zhí)行兩次$ pod repo update命令
我第二次執(zhí)行的時候完美更新成功:
Updating spec repo `trunk`
Updating spec repo `tsinghua-git-cocoapods`
$ /usr/bin/git -C /Users/maoyunhe/.cocoapods/repos/tsinghua-git-cocoapods
fetch origin --progress
$ /usr/bin/git -C /Users/maoyunhe/.cocoapods/repos/tsinghua-git-cocoapods
rev-parse --abbrev-ref HEAD
master
$ /usr/bin/git -C /Users/maoyunhe/.cocoapods/repos/tsinghua-git-cocoapods
reset --hard origin/master
HEAD is now at 026778590592 [Add] TM-PSDK 5.8.0-2.22.2
maodeMacBook-Pro: mao$
然后就可以使用命令:
$ pod install
來更新項目里面的三方了
Installing YZAuthID (2.0.0)
Installing ZCycleView (1.0.4)
Generating Pods project
Integrating client project
Pod installation complete! There are 21 dependencies from the Podfile and 22 total pods installed.
大功告成~~~~~~