更新flutter版本后提示cocoapods需要升级
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.4 18E226, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] Xcode - develop for iOS and macOS (Xcode 10.3)
! CocoaPods out of date (1.6.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin
code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade:
brew upgrade cocoapods
pod setup
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2017.1.4)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
直接运行提示的命令并没有升级成功
$ brew upgrade cocoapods
$ pod setup
改用下面方式升级
sudo gem install cocoapods
pod setup
遇到问题
$ sudo gem install cocoapods
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
解决:国内源 https://gems.ruby-china.org/ 改为 https://gems.ruby-china.com/ 了
# 移除源
$ gem source --remove https://gems.ruby-china.org/
#添加源
$ gem sources -a https://gems.ruby-china.com/
#查看源
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
Error fetching https://gems.ruby-china.com/:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://gems.ruby-china.com/specs.4.8.gz)
ruby没有包含SSL证书,所以Https的链接被服务器拒绝。
解决:下载证书(http://curl.haxx.se/ca/cacert.pem),添加环境变量 SSL_CERT_FILE 指向文件目录。