如何在使用VS Code运行Flutter doctor时修复’CocoaPods 1.8.4已过期’警告?

huangapple go评论54阅读模式
英文:

How can I fix 'CocoaPods 1.8.4 out of date' warning when running Flutter doctor on VS Code?

问题

我最近开始使用Flutter创建应用程序。希望有人能帮助我解决初学者的问题:

我按照这个入门视频中的步骤在VS Code中安装了Flutter插件,但是当我运行>Flutter: Run Flutter Doctor命令时,我收到了以下警告:

[!] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    ! CocoaPods 1.8.4 is out of date (1.11.0 is recommended).
        CocoaPods用于检索响应Dart端插件使用的iOS和macOS平台端的插件代码。
        如果没有CocoaPods,插件将无法在iOS或macOS上工作。
        有关更多信息,请参见https://flutter.dev/platform-plugins。
      要升级,请参见https://guides.cocoapods.org/using/getting-started.html#installation以获取说明。

我该如何解决这个警告?

当我在VS Code终端中检查CocoaPods的版本时,它返回1.12.1,而不是1.8.4

VS Code终端

~%gem list pod 

*** LOCAL GEMS ***

cocoapods (1.12.1)
cocoapods-core (1.12.1)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
cocoapods-try (1.2.0)

此外,我注意到VS Code的终端引用了与Mac OS不同的路径。

VS Code终端

~%which dart
/Users/{用户名}/development/flutter/bin/cache/dart-sdk/bin//dart

Mac OS终端

~%which dart
/Users/{用户名}/development/flutter/bin/dart

由于在Mac OS终端上运行flutter doctor成功,问题可能是错误的路径。(但是,VS Code如何覆盖PATH?我该如何解决?)

顺便说一下,在Mac OS终端上,flutter doctor成功运行,所以我认为最新版本的CocoaPods已经被下载。我只在运行命令面板中的Flutter: Run Flutter Doctor时遇到这个问题。

~%flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.2, on macOS 12.6.3 21G419 darwin-x64, locale
    en)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.78.2)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!
英文:

I've recently started creating an app by Flutter. Hope if anyone help me with my beginner question:

I installed the Flutter add-on to VS code following this introductory video, but I got a following warn when I run >Flutter: Run Flutter Doctor from the command pallet.

[!] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    ! CocoaPods 1.8.4 out of date (1.11.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.

How can I fix this warning?

When I check the cocoapods' version on VS Code terminal, it returns 1.12.1, not 1.8.4.

VS Code terminal

~%gem list pod 

*** LOCAL GEMS ***

cocoapods (1.12.1)
cocoapods-core (1.12.1)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
cocoapods-try (1.2.0)

Also, I noticed that VS Code's terminal refers to a different path from what Mac OS refers to.

VS Code terminal

~%which dart
/Users/{username}/development/flutter/bin/cache/dart-sdk/bin//dart

Mac OS terminal

~%which dart
/Users/{username}/development/flutter/bin/dart

As flutter doctor on Mac OS successes, the culprit might be this wrong PATH. (but, how does VS Code overwrite PATH? How can I fix it?)

By the way, on Mac OS terminal, flutter doctor successed, so I believe the latest cocoapods version itself has been downloaded. I get this problem only when I run Flutter: Run Flutter Doctor on command pallet.

~%flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.2, on macOS 12.6.3 21G419 darwin-x64, locale
    en)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.78.2)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

答案1

得分: 0

在VSCode中,从命令面板Cmd+Shift+P中打开JSON设置("Preferences: Open User Settings (JSON)")。尝试添加/编辑此行:

"dart.flutterSdkPath": "/Users/{username}/development/flutter",

然后重新启动计算机。

参考链接:https://stackoverflow.com/questions/51828255/visual-studio-code-dart-not-found

英文:

In VSCode, open JSON settings (Preferences: Open User Settings (JSON)) from the command palete Cmd+Shift+P. Try to add/edit this line:

"dart.flutterSdkPath": "/Users/{username}/development/flutter",

And restart computer.

Reference: https://stackoverflow.com/questions/51828255/visual-studio-code-dart-not-found

huangapple
  • 本文由 发表于 2023年5月28日 09:57:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76349676.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定