当前位置:   article > 正文

Mac上Flutter开发环境搭建_mac debug flutter

mac debug flutter
  1. 安装Dart SDK
brew tap dart-lang/dart
brew install dart
  • 1
  • 2
  1. 配置VSCode
    安装Dart、Code Runner插件
  2. 下载Flutter SDK
  3. 解压Flutter SDK压缩包到目标路径
  4. 配置flutter的PATH环境变量
    比如我的,在.zshrc文件中增加下面一行:
export PATH="$PATH:/Users/wlm/workspace/development/flutter/bin"
  • 1

通过下面两个命令验证PATH环境变量是否添加成功:

echo $PATH
which flutter
  • 1
  • 2
  1. 通过命令行创建一个Flutter应用
flutter create my_app
  • 1
  1. 启动应用
cd my_app
flutter run
  • 1
  • 2

报错:

Multiple devices found:
macOS (desktop) • macos  • darwin-x64     • macOS 12.1 21C52 darwin-x64
Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.124
[1]: macOS (macos)
[2]: Chrome (chrome)
Please choose one (To quit, press "q/Q"): 1
Launching lib/main.dart on macOS in debug mode...
ProcessException: Process exited abnormally:
xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH
  Command: xcrun xcodebuild -list -project Runner.xcodeproj
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

这是因为Mac电脑没有Xcode,安装后再次运行,出现下面的提示:

Building flutter tool...
Multiple devices found:
macOS (desktop) • macos  • darwin-x64     • macOS 12.1 21C52 darwin-x64
Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.124
[1]: macOS (macos)
[2]: Chrome (chrome)
Please choose one (To quit, press "q/Q"): 1
Running "flutter pub get" in my_app...                             505ms
Launching lib/main.dart on macOS in debug mode...
Building macOS application...
Syncing files to device macOS...                                   152ms

Flutter run key commands.
r Hot reload. 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/728568
推荐阅读
相关标签