最近长时间没有用自己的电脑进行项目开发,在使用pod install更新项目三方库的时候,发现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.
最后找到一个一发入魂的命令:
$ 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
更新成功后,再次执行命令:
$ 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
执行命令后可能会遇到一下错误:
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`
有可能是网速造成的错误:可以多执行两次$ pod repo update命令
我第二次执行的时候完美更新成功:
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.
大功告成~~~~~~