如何在 MacOS 上安装 Flutter ?

Flutter 是 Google 开发的一个功能强大的框架,它允许开发人员从单个代码库构建高质量的、本机编译的移动、web 和桌面应用程序。如果你是初次接触 Flutter,并希望在你的 macOS 系统上安装它,本指南将引导你一步一步地完成这个过程。

Step 1: Installing Homebrew

打开终端,粘贴如下命令并执行

复制代码
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

按照屏幕上的说明完成安装。你可能会被要求输入你的密码。

安装完成后,查看 brew 版本

复制代码
brew --version

Step 2: Installing Flutter

在终端中执行如下命令

复制代码
brew install --cask flutter

此命令将在 Mac 上下载并安装 Flutter,此过程可能需要一些时间。

安装完成后,查看 flutter 版本

复制代码
flutter --version

Step 3: Running Flutter Doctor

安装 Flutter 之后,运行 flutter doctor 命令非常重要,它将检查您的环境并报告任何缺失的依赖项。

复制代码
flutter doctor

Step 4: Installing Additional Tools

根据 flutter doctor 提供的说明,您可能需要安装其他工具。下面是我运行的命令,以确保一切设置正确。

Install Rosetta (required for Apple Silicon Macs)

复制代码
sudo softwareupdate --install-rosetta --agree-to-license

Install Android Studio (necessary for Android development)

复制代码
brew install --cask android-studio

Set Xcode's command-line tools location

复制代码
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Complete initial Xcode setup

复制代码
sudo xcodebuild -runFirstLaunch

Install CocoaPods (used for managing iOS dependencies)

复制代码
brew install cocoapods

Download iOS platform tools

复制代码
xcodebuild -downloadPlatform iOS

Step 5: Setting Up the Android Environment

要搭建 Android 环境,需要配置 Android SDK 并接受 license

Install the latest command-line tools for Android

复制代码
sdkmanager --install "cmdline-tools;latest"

Accept Android licenses

复制代码
flutter doctor --android-licenses

Set the Android SDK location (if not automatically detected)

复制代码
flutter config --android-sdk /path/to/your/android-sdk

Step 6: Running Flutter Doctor Again

现在所有工具和依赖项都已安装,再次运行 flutter doctor 以确保一切都正确设置。

复制代码
flutter doctor

如果一切都配置正确,您应该在每个项目旁边看到复选标记,表明环境已准备好,可以进行 Flutter 开发。

我的开源项目

相关推荐
末代iOS程序员华仔4 小时前
iOS 5.6 条例解决方法
flutter·ios·swift
OsDepK4 小时前
xcode应用构建至testflight测试流程
ide·macos·xcode
末代iOS程序员华仔10 小时前
Guideline 5.6 - Developer Code of Conduct
flutter·ios·swift
guo_wen_qiang11 小时前
一个好用的命令——查看文件大小
linux·macos
恋猫de小郭11 小时前
聊个比较有意思的 Flutter Web 问题
android·前端·flutter
2501_9159184111 小时前
Flutter项目配置iOS混淆的详细步骤与工具推荐
android·flutter·ios·小程序·uni-app·cocoa·iphone
天空之城--11 小时前
过去一周Android行业动态:编码技术与综合趋势精选
android·flutter·性能优化·kotlin·android jetpack
阿童木写作20 小时前
跨境电商图片翻译工具推荐:批量图片翻译+视频字幕翻译+智能抠图
python·macos·音视频·xcode
攀小黑1 天前
vue3+Web Speech API 封装了一个弹窗语音输入
前端·macos·xcode
Flutter OH1 天前
Flutter OH平台 DFX 问题定位导航
flutter