flutter-setting-up-on-macos
Original:🇺🇸 English
Not Translated
Sets up a macOS environment for Flutter development. Use when configuring a macOS machine to run, build, or deploy Flutter applications for iOS or macOS.
3installs
Sourcegsmlg-dev/code-agent
Added on
NPX Install
npx skill4agent add gsmlg-dev/code-agent flutter-setting-up-on-macosSKILL.md Content
Setting Up a macOS Environment for Flutter Development
Contents
- Prerequisites
- Tooling Configuration
- Workflow: Configuring macOS Tooling
- Workflow: Validating the Environment
- Troubleshooting
Prerequisites
Ensure the following baseline requirements are met before configuring the macOS-specific toolchain:
- macOS operating system.
- Flutter SDK installed and added to the system .
PATH - Active internet connection for downloading toolchains and dependencies.
Tooling Configuration
macOS desktop development requires specific Apple toolchains to compile and debug native Swift and Objective-C code.
- Xcode: Required for compiling macOS desktop applications.
- CocoaPods: Required for managing native dependencies used by Flutter plugins.
Workflow: Configuring macOS Tooling
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:
Conditional: If Xcode is installed in a custom directory, replacebash
sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'with the correct absolute path./Applications/Xcode.app - Accept Xcode Licenses: Accept the required developer licenses by running:
Read and agree to the prompts.bash
sudo xcodebuild -license - Install CocoaPods: Install CocoaPods to handle native macOS plugin dependencies.
Conditional: If CocoaPods is already installed, ensure it is updated to the latest version (bash
sudo gem install cocoapods).sudo gem update cocoapods
Workflow: Validating the Environment
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:
bash
flutter doctor -v - Review Errors: Check the section in the output.
Xcode - Fix & Retry: If errors or missing components are reported under the Xcode section, resolve them according to the output instructions, then re-run until the Xcode section passes.
flutter doctor -v - Verify Device Availability: Confirm that Flutter recognizes the macOS desktop as a valid deployment target:
Success Criteria: The output must contain at least one entry withbash
flutter deviceslisted as the platform.macos
Troubleshooting
If the validation workflow fails, apply the following resolutions:
- Missing Command-Line Tools: If reports missing tools, ensure the
flutter doctorcommand was run withxcode-selectand points to the correctsudodirectory..app - CocoaPods Not Found: If CocoaPods is installed but not detected, verify that your Ruby binary path is included in your shell's
gemenvironment variable.PATH - Device Not Listed: If does not list
flutter devices, ensure desktop support is enabled in your Flutter configuration:macosbashflutter config --enable-macos-desktop