flutter-environment-setup-macos by flutter/skills
npx skills add https://github.com/flutter/skills --skill flutter-environment-setup-macos配置一个用于构建、运行和部署 Flutter 应用程序的 macOS 开发环境。验证包括 Xcode 和 CocoaPods 在内的工具依赖项,并确保环境通过 Flutter 针对 macOS 桌面开发的诊断检查。假设主机操作系统是 macOS 且用户拥有管理员权限。
验证 Flutter 安装 检查 Flutter 是否已安装并在当前环境中可访问。
flutter --version
决策逻辑:
* 如果命令执行失败,**停止并询问用户:** "Flutter 未安装或不在您的 PATH 环境变量中。请先安装 Flutter 并将其添加到 PATH 中,然后再继续。"
* 如果命令执行成功,则继续步骤 2。
2. 验证 Xcode 安装 确保 macOS 系统上已安装 Xcode。
xcodebuild -version
决策逻辑:
* 如果 Xcode 未安装,**停止并询问用户:** "macOS Flutter 开发需要 Xcode。请从 Mac App Store 安装最新版本的 Xcode,并在完成后通知我。"
* 如果 Xcode 已安装,则继续步骤 3。
3. 配置 Xcode 命令行工具 将 Xcode 命令行工具链接到已安装的 Xcode 版本,并运行首次启动设置。停止并询问用户: "我需要配置 Xcode 命令行工具。这需要管理员权限。请在您的终端中运行以下命令,并在完成后确认:"
sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
(注意:如果用户将 Xcode 安装在了非标准目录,请指导他们用自定义路径替换 /Applications/Xcode.app)。
接受 Xcode 许可协议 在开始编译之前,必须接受 Xcode 许可协议。停止并询问用户: "请运行以下命令以查看并接受 Xcode 许可协议:"
sudo xcodebuild -license
安装 CocoaPods 对于使用原生 macOS 代码的 Flutter 插件,需要 CocoaPods。检查是否已安装 CocoaPods:
pod --version
决策逻辑:
* 如果已安装,则继续步骤 6。
* 如果未安装,则指导用户安装它(例如,通过 Homebrew 或 RubyGems)并验证安装。
sudo gem install cocoapods
6. 验证设置(验证并修复循环) 运行 Flutter 诊断工具,检查是否存在任何剩余的 macOS 工具链问题。
flutter doctor -v
决策逻辑:
* 分析 **Xcode** 部分下的输出。
* 如果存在错误或缺少组件,识别具体的缺失依赖项,向用户提供确切的修复命令,并重新运行 `flutter doctor -v`。
* 重复此循环,直到 Xcode 部分报告没有问题。
7. 验证设备可用性 确保 Flutter 能够检测到 macOS 桌面作为有效的部署目标。
flutter devices
验证输出中至少有一个条目将 "macos" 列为平台。如果缺失,则指导用户启用 macOS 桌面支持:
flutter config --enable-macos-desktop
sudo 命令;始终暂停并提供确切的命令供用户执行。flutter doctor 的 Xcode 部分完全没有错误,才能认为此技能完成。每周安装次数
869
代码仓库
GitHub 星标数
822
首次出现
2026年3月4日
安全审计
已安装于
codex829
gemini-cli826
cursor826
opencode825
github-copilot824
amp824
Configures a macOS development environment for building, running, and deploying Flutter applications. Validates tooling dependencies including Xcode and CocoaPods, and ensures the environment passes Flutter's diagnostic checks for macOS desktop development. Assumes the host operating system is macOS and the user has administrative privileges.
Verify Flutter Installation Check if Flutter is installed and accessible in the current environment.
flutter --version
Decision Logic:
* If the command fails, **STOP AND ASK THE USER:** "Flutter is not installed or not in your PATH. Please install Flutter and add it to your PATH before continuing."
* If the command succeeds, proceed to step 2.
2. Verify Xcode Installation Ensure Xcode is installed on the macOS system.
xcodebuild -version
Decision Logic:
* If Xcode is not installed, **STOP AND ASK THE USER:** "Xcode is required for macOS Flutter development. Please install the latest version of Xcode from the Mac App Store and notify me when complete."
* If Xcode is installed, proceed to step 3.
3. Configure Xcode Command-Line Tools Link the Xcode command-line tools to the installed version of Xcode and run the first-launch setup. STOP AND ASK THE USER: "I need to configure Xcode command-line tools. This requires administrative privileges. Please run the following command in your terminal and confirm when done:"
sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'
(Note: If the user installed Xcode in a non-standard directory, instruct them to replace/Applications/Xcode.app with their custom path).
Accept Xcode Licenses The Xcode license agreements must be accepted before compilation can occur. STOP AND ASK THE USER: "Please run the following command to review and accept the Xcode license agreements:"
sudo xcodebuild -license
Install CocoaPods CocoaPods is required for Flutter plugins that utilize native macOS code. Check if CocoaPods is installed:
pod --version
Decision Logic:
* If installed, proceed to step 6.
* If not installed, instruct the user to install it (e.g., via Homebrew or RubyGems) and verify the installation.
sudo gem install cocoapods
6. Validate Setup (Validate-and-Fix Loop) Run the Flutter diagnostic tool to check for any remaining macOS toolchain issues.
flutter doctor -v
Decision Logic:
* Analyze the output under the **Xcode** section.
* If there are errors or missing components, identify the specific missing dependency, provide the user with the exact command to fix it, and re-run `flutter doctor -v`.
* Repeat this loop until the Xcode section reports no issues.
7. Verify Device Availability Ensure Flutter can detect the macOS desktop as a valid deployment target.
flutter devices
Verify that at least one entry in the output has "macos" listed as the platform. If it is missing, instruct the user to enable macOS desktop support:
flutter config --enable-macos-desktop
sudo commands automatically; always pause and provide the exact command for the user to execute.flutter doctor Xcode section is completely clear of errors before considering the skill complete.Weekly Installs
869
Repository
GitHub Stars
822
First Seen
Mar 4, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex829
gemini-cli826
cursor826
opencode825
github-copilot824
amp824
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装