Almost similar issue at flutter run. I didn't want to upgrade XCode or macOS
Could not build the precompiled application for the device.
Lexical or Preprocessor Issue (Xcode): 'messages.g.h' file not found
/Users/noneofyourbusiness/.pub-cache/hosted/pub.dev/wakelock_plus-1.3.0/ios/wakelock_plus/Sources/wakelock_plus/WakelockPlusPlugin.m:1:8
Sorted this by having to add into wakelock_plus in pubspec.yaml
wakelock_plus: ^1.4.0
I hope this helps someone who is stuck on a Saturday night.
Maybe I could resolve this by deleting DerivedData?