Solve the problem that the Cocoapods version does not take effect after reinstallation or update

scene

Sometimes when running flutter doctor, the following prompt will appear

$ 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.

According to the above error message, the current version of Cocoapods is 1.5.0, which is too low, and needs to be above 1.10.0.

After we sudo gem install cocoapodsreinstalled the latest version using , pod --versionthe printed version information remained unchanged.

$ pod --version
1.5.0

solution

method 1

If you are using the gem install cocoapodsinstalled one, add parameters after it to overwrite the installation.

$ 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 doctorThere will be no error when running .

Method 2

If you are using brewnewer cocoapods, you need to override it with the following command.

$ brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.10.1... 2 symlinks created.
# 再次检查版本,版本已经生效。
$ pod --version                   
1.10.1

Finally run flutter doctor, you can see that it is normal.

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)

Guess you like

Origin blog.csdn.net/adojayfan/article/details/125670315