1.3 KiB
1.3 KiB
macOS 编译测试指南
快速开始
cd /Users/yuantiancai/work/FocusBuddy
flutter pub get
flutter run -d macos
环境要求
Flutter
Flutter 已安装在 /Users/yuantiancai/sdk/flutter
# 添加到 PATH
export PATH="$PATH:$HOME/sdk/flutter/bin"
source ~/.zshrc
Xcode
从 Mac App Store 安装 Xcode,然后:
sudo xcodebuild -license accept
CocoaPods
使用 rbenv 安装 Ruby 3.x 和 CocoaPods:
# 安装 rbenv
brew install rbenv ruby-build
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
source ~/.zshrc
# 安装 Ruby 3.3.8
rbenv install 3.3.8
rbenv global 3.3.8
# 安装 CocoaPods
gem install cocoapods
编译运行
# macOS 桌面
flutter run -d macos
# iOS 模拟器
open -a Simulator
flutter run -d ios
# Release 版本
flutter build macos --release
# 输出:build/macos/Build/Products/Release/focus_buddy.app
常见问题
CocoaPods 错误
cd ios && pod install && cd ..
flutter clean && flutter pub get
构建缓存问题
flutter clean
flutter pub get
Xcode 签名
打开 ios/Runner.xcworkspace,在 "Signing & Capabilities" 配置开发团队
开发提示
运行时快捷键:
r- 热重载R- 热重启q- 退出
代码检查:
flutter analyze
flutter test