Fixing `xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH`
Today I tried to run a Desktop (macOS) Flutter app that used to run perfectly. This time, instead of launching, it threw this error:
Launching lib/main.dart on macOS in debug mode... lib/main.dart:1ProcessException: Process exited abnormally: xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH Command: /usr/bin/arch -arm64e xcrun xcodebuild -list -project Runner.xcodeproj Exited (sigterm)
I have no idea why it happened, but as explained in this StackOverflow post, setting the path in XCode, Preferences, Locations did the trick. On my machine, the path for Command Line Tools was empty. I selected the only option in it, and my project launched fine again.