[flutter_tools] Handle missing Xcode gracefully in getInfo and buildMacOS (#191180)
Fixes https://github.com/flutter/flutter/issues/191176 ### Problem In Flutter 3.47.0 telemetry, an unhandled `ProcessException` when invoking `xcodebuild` emerged as a top crash signature. When running `flutter build macos` on a machine where Xcode is not installed, incomplete, or misconfigured, `flutter_tools` crashes with an unhandled `ProcessException` instead of providing a graceful `ToolExit` error message. ### Root Cause 1. `buildMacOS` in `packages/flutter_tools/lib/src/macos/build_macos.dart` lacked pre-flight toolchain validation (`globals.xcodeProjectInterpreter?.isInstalled != true`) before querying Xcode project information. 2. In `XcodeProjectInterpreter.getInfo` (`packages/flutter_tools/lib/src/ios/xcodeproj.dart`), `xcodebuild -list` is executed with `throwOnError: true` while only allowing exit codes 66 and 74. When `xcrun` returns exit code 72 (unable to find utility "xcodebuild"), `_processUtils.run` throws an uncaught `ProcessException`. 3. `buildMacOS` improperly used non-null assertions on `projectInfo!` when resolving build schemes. ### Fix - Added pre-flight Xcode toolchain check in `buildMacOS` to exit early with `globals.userMessages.xcodeMissing`. - Wrapped `XcodeProjectInterpreter.getInfo` in a `try ... on ProcessException` block to convert unexpected process failures to user-friendly `ToolExit` messages. - Added safe null checks on `projectInfo` in `buildMacOS`.
B
Ben Konyi committed
fbb2656385ada4b6b1ed0fc8f78fedb975fc12f4
Parent: 0c0d059
Committed by GitHub <noreply@github.com>
on 8/24/2026, 5:32:49 PM