Fix bundle id on iOS launch using flutter run (#31039)
diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart
index 3596c6e..428e154 100644
--- a/packages/flutter_tools/lib/src/ios/simulators.dart
+++ b/packages/flutter_tools/lib/src/ios/simulators.dart
@@ -23,6 +23,7 @@
import '../protocol_discovery.dart';
import 'ios_workflow.dart';
import 'mac.dart';
+import 'plist_utils.dart';
const String _xcrunPath = '/usr/bin/xcrun';
@@ -343,7 +344,15 @@
// Launch the updated application in the simulator.
try {
- await SimControl.instance.launch(id, package.id, args);
+ // Use the built application's Info.plist to get the bundle identifier,
+ // which should always yield the correct value and does not require
+ // parsing the xcodeproj or configuration files.
+ // See https://github.com/flutter/flutter/issues/31037 for more information.
+ final IOSApp iosApp = package;
+ final String plistPath = fs.path.join(iosApp.simulatorBundlePath, 'Info.plist');
+ final String bundleIdentifier = iosWorkflow.getPlistValueFromFile(plistPath, kCFBundleIdentifierKey);
+
+ await SimControl.instance.launch(id, bundleIdentifier, args);
} catch (error) {
printError('$error');
return LaunchResult.failed();