Opening a Flutter app in Xcode should open Runner.xcworkspace, not Runner.xcodeproj.
See https://flutter.dev/docs/deployment/ios#create-a-build-archive and flutter/flutter#10770
User report from @kinex at firebase/flutterfire#1258 (comment)
I had opened it from VS Code by right-clicking in the explorer MyApp / ios folder and then selecting Open in Xcode. Apparently it opens Runner.xcodeproj because if I now open Runner.xcworkspace directly, I can create an archive normally. Not sure is there some reason that VS Code opens .xcodeproj or is that something that should be fixed.
I wasn't able to reproduce this myself due to #2178.
Logic at
| .sort((f1, f2) => f1.name.endsWith(".xcworkspace") ? 0 : 1); |
looks right to me, but I'm not sure what version @kinex is on.