我最近开始创建一个由Flutter开发的应用。希望有人能帮我解答一下初学者的问题:
我在this introductory video之后将Flutter附加组件安装到VS代码中,但是当我从命令托盘运行>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 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.
如何修复此警告?
当我在VS Code终端上检查cocoapods的版本时,它返回1.12.1
,而不是1.8.4
。
VS代码终端
~%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代码终端
~%which dart
/Users/{username}/development/flutter/bin/cache/dart-sdk/bin//dart
Mac OS终端
~%which dart
/Users/{username}/development/flutter/bin/dart
正如flutter doctor
在Mac OS上的成功,罪魁祸首可能是这个错误的路径。(但是,VS Code是如何覆盖PATH的?)我该怎么解决?)
顺便说一句,在Mac OS终端上,Flutter医生成功了,所以我相信最新的cocoapods版本本身已经下载。只有当我在命令pallet上运行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!
1条答案
按热度按时间yptwkmov1#
在VSCode中,通过命令palete Cmd+Shift+ P打开JSON设置(
Preferences: Open User Settings (JSON)
)。尝试添加/编辑此行:然后重新启动计算机。
参考:Visual Studio Code: dart not found