flutter-setting-up-on-macos by flutter/skills
npx skills add https://github.com/flutter/skills --skill flutter-setting-up-on-macos在配置 macOS 特定的工具链之前,请确保满足以下基本要求:
PATH 中。macOS 桌面开发需要特定的 Apple 工具链来编译和调试原生的 Swift 和 Objective-C 代码。
复制并遵循此检查清单来配置 macOS 构建环境。
安装 Xcode :从 Mac App Store 或 Apple 开发者门户安装最新版本的 Xcode。
配置命令行工具 :将 Xcode 命令行工具链接到已安装的 Xcode 版本。在终端中运行以下命令:
sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'
条件性 :如果 Xcode 安装在自定义目录中,请将 替换为正确的绝对路径。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
/Applications/Xcode.app接受 Xcode 许可证 :通过运行以下命令接受所需的开发者许可证:
sudo xcodebuild -license
阅读并同意提示。
安装 CocoaPods :安装 CocoaPods 以处理原生的 macOS 插件依赖项。
sudo gem install cocoapods
条件性 :如果已安装 CocoaPods,请确保其更新到最新版本 (sudo gem update cocoapods)。
执行此反馈循环以确保环境已正确配置用于 macOS 桌面开发。
运行验证器 :执行 Flutter 诊断工具并输出详细信息:
flutter doctor -v
检查错误 :检查输出中的 Xcode 部分。
修复并重试:如果在 Xcode 部分报告了错误或缺失的组件,请根据输出说明解决它们,然后重新运行 flutter doctor -v,直到 Xcode 部分通过。
验证设备可用性 :确认 Flutter 将 macOS 桌面识别为有效的部署目标:
flutter devices
成功标准 :输出必须至少包含一个将 macos 列为平台的条目。
如果验证工作流程失败,请应用以下解决方案:
缺少命令行工具 :如果 flutter doctor 报告缺少工具,请确保 xcode-select 命令已使用 sudo 运行并指向正确的 .app 目录。
未找到 CocoaPods :如果已安装 CocoaPods 但未检测到,请验证你的 Ruby gem 二进制路径是否包含在 shell 的 PATH 环境变量中。
未列出设备 :如果 flutter devices 未列出 macos,请确保在你的 Flutter 配置中启用了桌面支持:
flutter config --enable-macos-desktop
每周安装量
1.6K
代码仓库
GitHub 星标数
792
首次出现
12 天前
安全审计
安装于
codex1.6K
opencode1.6K
github-copilot1.6K
gemini-cli1.6K
kimi-cli1.6K
cursor1.6K
Ensure the following baseline requirements are met before configuring the macOS-specific toolchain:
PATH.macOS desktop development requires specific Apple toolchains to compile and debug native Swift and Objective-C code.
Copy and follow this checklist to configure the macOS build environment.
Install Xcode : Install the latest version of Xcode from the Mac App Store or the Apple Developer portal.
Configure Command-Line Tools : Link the Xcode command-line tools to the installed Xcode version. Run the following command in the terminal:
sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'
Conditional : If Xcode is installed in a custom directory, replace /Applications/Xcode.app with the correct absolute path.
Accept Xcode Licenses : Accept the required developer licenses by running:
sudo xcodebuild -license
Read and agree to the prompts.
Install CocoaPods : Install CocoaPods to handle native macOS plugin dependencies.
sudo gem install cocoapods
Conditional : If CocoaPods is already installed, ensure it is updated to the latest version (sudo gem update cocoapods).
Execute this feedback loop to ensure the environment is correctly configured for macOS desktop development.
Run Validator : Execute the Flutter diagnostic tool with verbose output:
flutter doctor -v
Review Errors : Check the Xcode section in the output.
Fix & Retry: If errors or missing components are reported under the Xcode section, resolve them according to the output instructions, then re-run flutter doctor -v until the Xcode section passes.
Verify Device Availability : Confirm that Flutter recognizes the macOS desktop as a valid deployment target:
flutter devices
Success Criteria : The output must contain at least one entry with macos listed as the platform.
If the validation workflow fails, apply the following resolutions:
Missing Command-Line Tools : If flutter doctor reports missing tools, ensure the xcode-select command was run with sudo and points to the correct .app directory.
CocoaPods Not Found : If CocoaPods is installed but not detected, verify that your Ruby gem binary path is included in your shell's PATH environment variable.
Device Not Listed : If flutter devices does not list macos, ensure desktop support is enabled in your Flutter configuration:
flutter config --enable-macos-desktop
Weekly Installs
1.6K
Repository
GitHub Stars
792
First Seen
12 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex1.6K
opencode1.6K
github-copilot1.6K
gemini-cli1.6K
kimi-cli1.6K
cursor1.6K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装