一、安装基础软件
Windows
winget install Microsoft.VisualStudio.2022.Community --override "--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive --norestart"
winget install Git.Git
winget install Kitware.CMake
winget install Ninja-build.Ninja
MacOS
# 安装 Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install git
二、安装 Flutter SDK
Windows
mkdir %USERPROFILE%\sdk
下载flutter
解压
Expand-Archive `
-Path "$env:USERPROFILE\Downloads\flutter_windows_3.29.3-stable.zip" `
-DestinationPath "$env:USERPROFILE\sdk" `
-Force
增加环境变量, 电脑右键属性,高级属性,环境变量,用户的环境变量,Path追加下面的路径
添加环境变量 PATH:%USERPROFILE%\sdk\flutter
\bin
MacOS
mkdir -p /Volumes/mindata/Applications/aarch64 && cd /Volumes/mindata/Applications/aarch64
git clone https://github.com/flutter/flutter.git -b 3.29.3
把 flutter/bin
加入 PATH(zsh 为例):
echo 'export PATH="$PATH:/Volumes/mindata/Applications/aarch64/flutter/bin"' >> ~/.zshrc
source ~/.zshrc
第一次用可能被 Gatekeeper 隔离,遇到权限或打不开时可去掉隔离:
xattr -dr com.apple.quarantine /Volumes/mindata/Applications/aarch64/flutter
三、预拉取依赖并体检
Windows
flutter config --enable-windows-desktop
flutter precache --windows
flutter doctor -v
make windows-prepare
flutter precache --windows
如果有目录libcorebin文件夹,需要改成libcore/bin
MacOS
flutter precache --ios --android
flutter doctor
flutter doctor -v # 如果排查问题,用详细输出
make macos-prepare
make ios-prepare
make android-prepare
四、创建iOS 开发环境
MacOS
从 App Store 安装 Xcode,首次打开让它完成组件安装
接受许可并设置命令行工具:
sudo xcodebuild -license accept
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
安装 CocoaPods(Apple Silicon 推荐用 brew 安装):
brew install cocoapods
pod setup
打开 Xcode → Preferences → Locations → Command Line Tools 选择对应版本
iOS 模拟器:open -a Simulator
五、Android 开发环境(可选)
安装 Android Studio
打开 Android Studio → SDK Manager 勾选:
- Android SDK Platform(推荐最新稳定版本)
- Android SDK Platform-Tools
- Android SDK Build-Tools
- 需要的系统镜像(Arm64 for Apple Silicon)
安装 JDK 17(AGP 当前广泛兼容)
配置环境变量(zsh):
echo 'export ANDROID_SDK_ROOT="/Volumes/mindata/Applications/Android/sdk"' >> ~/.zshrc
echo 'export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/tools/bin"' >> ~/.zshrc
source ~/.zshrc
让 Flutter 识别 Android Studio(如需要)
flutter config --android-studio-dir="/Volumes/mindata/Applications/aarch64/Android Studio.app/Contents"
flutter doctor
六、Windows开发环境
安装make
iwr -useb get.scoop.sh | iex
scoop install make cmake
flutter clean
flutter pub get
八、快速验证
flutter create hello_app
cd hello_app
flutter run -d ios # 跑 iOS 模拟器
# 或
flutter run -d android # 跑 Android 模拟器/真机