|
| 1 | +--- |
| 2 | +title: Set up macOS development |
| 3 | +description: >- |
| 4 | + Configure your development environment to |
| 5 | + run, build, and deploy Flutter apps for macOS devices. |
| 6 | +--- |
| 7 | + |
| 8 | +Learn how to set up your development environment |
| 9 | +to run, build, and deploy Flutter apps for the macOS desktop platform. |
| 10 | + |
| 11 | +:::note |
| 12 | +If you haven't set up Flutter already, |
| 13 | +visit and follow the [Get started with Flutter][] guide first. |
| 14 | + |
| 15 | +If you've already installed Flutter, |
| 16 | +ensure that it's [up to date][]. |
| 17 | +::: |
| 18 | + |
| 19 | +[Get started with Flutter]: /get-started/install |
| 20 | +[up to date]: /install/upgrade |
| 21 | + |
| 22 | +## Set up tooling {: #set-up-tooling} |
| 23 | + |
| 24 | +With Xcode, you can run Flutter apps on macOS as well as |
| 25 | +compile and debug native Swift and Objective-C code. |
| 26 | + |
| 27 | + 1. <h3>Install Xcode</h3> |
| 28 | + |
| 29 | + If you haven't done so already, |
| 30 | + [install and set up the latest version of Xcode][xcode]. |
| 31 | + |
| 32 | + If you've already installed Xcode, |
| 33 | + update it to the latest version using the |
| 34 | + same installation method you used originally. |
| 35 | + |
| 36 | + 1. <h3>Set up Xcode command-line tools</h3> |
| 37 | + |
| 38 | + To configure the Xcode command-line tools to use |
| 39 | + the version of Xcode you installed, |
| 40 | + run the following command in your preferred terminal: |
| 41 | + |
| 42 | + ```console |
| 43 | + $ sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch' |
| 44 | + ``` |
| 45 | + |
| 46 | + If you downloaded Xcode elsewhere or need to use a different version, |
| 47 | + replace `/Applications/Xcode.app` with the path to there instead. |
| 48 | + |
| 49 | + 1. <h3>Agree to the Xcode licenses</h3> |
| 50 | + |
| 51 | + After you've set up Xcode and configured its command-line tools, |
| 52 | + agree to the Xcode licenses. |
| 53 | + |
| 54 | + 1. Open your preferred terminal. |
| 55 | + |
| 56 | + 1. Run the following command to review and sign the Xcode licenses. |
| 57 | + |
| 58 | + ```console |
| 59 | + $ sudo xcodebuild -license |
| 60 | + ``` |
| 61 | + |
| 62 | + 1. Read and agree to all necessary licenses. |
| 63 | + |
| 64 | + Before agreeing to the terms of each license, |
| 65 | + read each with care. |
| 66 | + |
| 67 | + Once you've accepted all the necessary licenses successfully, |
| 68 | + the command should output how to review the licenses. |
| 69 | + |
| 70 | + 1. <h3>Install CocoaPods</h3> |
| 71 | + |
| 72 | + To support [Flutter plugins][] that use native macOS code, |
| 73 | + install the latest version of [CocoaPods][]. |
| 74 | + |
| 75 | + Install CocoaPods following the |
| 76 | + [CocoaPods installation guide][]. |
| 77 | + |
| 78 | + If you've already installed CocoaPods, |
| 79 | + update it following the [CocoaPods update guide][]. |
| 80 | + |
| 81 | +{: .steps} |
| 82 | + |
| 83 | +[xcode]: https://developer.apple.com/xcode/ |
| 84 | +[Flutter plugins]: /packages-and-plugins/developing-packages#types |
| 85 | +[CocoaPods]: https://cocoapods.org/ |
| 86 | +[CocoaPods installation guide]: https://guides.cocoapods.org/using/getting-started.html#installation |
| 87 | +[CocoaPods update guide]: https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods |
| 88 | + |
| 89 | +## Validate your setup {: #validate-setup} |
| 90 | + |
| 91 | + 1. <h3>Check for toolchain issues</h3> |
| 92 | + |
| 93 | + To check for any issues with your macOS development setup, |
| 94 | + run the `flutter doctor` command in your preferred terminal: |
| 95 | + |
| 96 | + ```console |
| 97 | + $ flutter doctor -v |
| 98 | + ``` |
| 99 | + |
| 100 | + If you see any errors or tasks to complete |
| 101 | + under the **Xcode** section, |
| 102 | + complete and resolve them, then |
| 103 | + run `flutter doctor -v` again to verify any changes. |
| 104 | + |
| 105 | + 1. <h3>Check for macOS devices</h3> |
| 106 | + |
| 107 | + To ensure Flutter can find and connect to your macOS device correctly, |
| 108 | + run `flutter devices` in your preferred terminal: |
| 109 | + |
| 110 | + ```console |
| 111 | + $ flutter devices |
| 112 | + ``` |
| 113 | + |
| 114 | + If you set everything up correctly, |
| 115 | + there should be at least one entry with the platform marked as **macos**. |
| 116 | + |
| 117 | + 1. <h3>Troubleshoot setup issues</h3> |
| 118 | + |
| 119 | + If you need help resolving any setup issues, |
| 120 | + check out [Install and setup troubleshooting][]. |
| 121 | + |
| 122 | + If you still have issues or questions, |
| 123 | + reach out on one of the Flutter [community][] channels. |
| 124 | + |
| 125 | +{: .steps} |
| 126 | + |
| 127 | +[Install and setup troubleshooting]: /install/troubleshoot |
| 128 | +[community]: {{site.main-url}}/community |
| 129 | + |
| 130 | +## Start developing for macOS {: #start-developing} |
| 131 | + |
| 132 | +Congratulations! |
| 133 | +Now that you've set up macOS desktop development for Flutter, |
| 134 | +you can continue your Flutter learning journey while testing on macOS |
| 135 | +or begin expanding integration with macOS. |
| 136 | + |
| 137 | +<div class="card-grid link-cards"> |
| 138 | + <div class="card filled-card list-card"> |
| 139 | + <div class="card-leading"> |
| 140 | + <img src="/assets/images/decorative/pointing-the-way.png" height="160" aria-hidden="true" alt="Dash helping you explore Flutter learning resources."> |
| 141 | + </div> |
| 142 | + <div class="card-header"> |
| 143 | + <span class="card-title">Continue learning Flutter</span> |
| 144 | + </div> |
| 145 | + <div class="card-content"> |
| 146 | + <ul> |
| 147 | + <li> |
| 148 | + <a class="text-button" href="/get-started/codelab">Write your first app</a> |
| 149 | + </li> |
| 150 | + <li> |
| 151 | + <a class="text-button" href="/get-started/fundamentals">Learn the fundamentals</a> |
| 152 | + </li> |
| 153 | + <li> |
| 154 | + <a class="text-button" href="https://www.youtube.com/watch?v=b_sQ9bMltGU&list=PLjxrf2q8roU23XGwz3Km7sQZFTdB996iG">Explore Flutter widgets</a> |
| 155 | + </li> |
| 156 | + <li> |
| 157 | + <a class="text-button" href="/reference/learning-resources">Check out samples</a> |
| 158 | + </li> |
| 159 | + <li> |
| 160 | + <a class="text-button" href="/resources/bootstrap-into-dart">Learn about Dart</a> |
| 161 | + </li> |
| 162 | + </ul> |
| 163 | + </div> |
| 164 | + </div> |
| 165 | + <div class="card filled-card list-card"> |
| 166 | + <div class="card-leading"> |
| 167 | + <img src="/assets/images/decorative/flutter-on-desktop.svg" height="160" aria-hidden="true" alt="An outline of Flutter desktop support."> |
| 168 | + </div> |
| 169 | + <div class="card-header"> |
| 170 | + <span class="card-title">Build for macOS</span> |
| 171 | + </div> |
| 172 | + <div class="card-content"> |
| 173 | + <ul> |
| 174 | + <li> |
| 175 | + <a class="text-button" href="/deployment/macos">Build and deploy to macOS</a> |
| 176 | + </li> |
| 177 | + <li> |
| 178 | + <a class="text-button" href="/platform-integration/macos/c-interop">Bind to native macOS code</a> |
| 179 | + </li> |
| 180 | + <li> |
| 181 | + <a class="text-button" href="/platform-integration/macos/platform-views">Embed native macOS views</a> |
| 182 | + </li> |
| 183 | + <li> |
| 184 | + <a class="text-button" href="/deployment/flavors-ios">Set up app flavors</a> |
| 185 | + </li> |
| 186 | + <li> |
| 187 | + <a class="text-button" href="/packages-and-plugins/swift-package-manager/for-app-developers">Use Swift Package Manager</a> |
| 188 | + </li> |
| 189 | + </ul> |
| 190 | + </div> |
| 191 | + </div> |
| 192 | +</div> |
0 commit comments