出现场景
有时候在运行flutter doctor
时,会出现以下提示
$ flutter doctor [!] Xcode - develop for iOS and macOS ! CocoaPods 1.5.0 out of date (1.10.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 see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
根据上面的错误 提示,当前Cocoapods的版本是1.5.0,太低了,需要1.10.0以上才行。
我们使用sudo gem install cocoapods
重新安装最新的版本后,使用pod --version
打印出来的版本信息依然没改变。
$ pod --version 1.5.0
解决方案
方法1
如果使用的是gem install cocoapods
安装的,后面加上参数,覆盖安装。
$ sudo gem install cocoapods -n/usr/local/bin Successfully installed cocoapods-1.10.1 Parsing documentation for cocoapods-1.10.1 Done installing documentation for cocoapods after 1 seconds 1 gem installed # 再次检查版本,可以看到版本已经更新。 $ pod --version 1.10.1
运行flutter doctor
也不会出现错误了。
方法2
如果使用的是brew
更新的cocoapods,需要使用以下命令覆盖。
$ brew link --overwrite cocoapods Linking /usr/local/Cellar/cocoapods/1.10.1... 2 symlinks created. # 再次检查版本,版本已经生效。 $ pod --version 1.10.1
最后运行flutter doctor
,可以看到已经正常了。
mydeMacBook-Pro$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-x64, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 13.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.61.0) [✓] VS Code (version 1.61.0) [✓] Connected device (2 available)