build ios-framework simulator slices for profile/release (#73378)

diff --git a/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart b/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart
index bdfa1b5..539f71f 100644
--- a/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart
+++ b/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart
@@ -191,7 +191,7 @@
 
   section('Check debug build has no Dart AOT');
 
-  final String aotSymbols = await dylibSymbols(debugAppFrameworkPath);
+  final String aotSymbols = await _dylibSymbols(debugAppFrameworkPath);
 
   if (aotSymbols.contains('architecture') ||
       aotSymbols.contains('_kDartVmSnapshot')) {
@@ -212,7 +212,7 @@
 
     await _checkBitcode(appFrameworkPath, mode);
 
-    final String aotSymbols = await dylibSymbols(appFrameworkPath);
+    final String aotSymbols = await _dylibSymbols(appFrameworkPath);
 
     if (!aotSymbols.contains('_kDartVmSnapshot')) {
       throw TaskResult.failure('$mode App.framework missing Dart AOT');
@@ -228,7 +228,7 @@
       'vm_snapshot_data',
     ));
 
-    checkFileNotExists(path.join(
+    checkFileExists(path.join(
       outputPath,
       mode,
       'App.xcframework',
@@ -314,13 +314,8 @@
       'DeviceInfoPlugin.h',
     );
 
-    if (mode == 'Debug') {
-      checkFileExists(simulatorFrameworkPath);
-      checkFileExists(simulatorFrameworkHeaderPath);
-    } else {
-      checkFileNotExists(simulatorFrameworkPath);
-      checkFileNotExists(simulatorFrameworkHeaderPath);
-    }
+    checkFileExists(simulatorFrameworkPath);
+    checkFileExists(simulatorFrameworkHeaderPath);
   }
 
   section('Check all modes have generated plugin registrant');
@@ -357,11 +352,7 @@
       'Headers',
       'GeneratedPluginRegistrant.h',
     );
-    if (mode == 'Debug') {
-      checkFileExists(simulatorHeaderPath);
-    } else {
-      checkFileNotExists(simulatorHeaderPath);
-    }
+    checkFileExists(simulatorHeaderPath);
   }
 
   // This builds all build modes' frameworks by default
@@ -443,3 +434,12 @@
     throw TaskResult.failure('$frameworkPath does not contain bitcode');
   }
 }
+
+Future<String> _dylibSymbols(String pathToDylib) {
+  return eval('nm', <String>[
+    '-g',
+    pathToDylib,
+    '-arch',
+    'arm64',
+  ]);
+}
diff --git a/dev/devicelab/lib/framework/ios.dart b/dev/devicelab/lib/framework/ios.dart
index da5b717..0a1759e 100644
--- a/dev/devicelab/lib/framework/ios.dart
+++ b/dev/devicelab/lib/framework/ios.dart
@@ -10,10 +10,6 @@
 
 typedef SimulatorFunction = Future<void> Function(String deviceId);
 
-Future<String> dylibSymbols(String pathToDylib) {
-  return eval('nm', <String>['-g', pathToDylib]);
-}
-
 Future<String> fileType(String pathToBinary) {
   return eval('file', <String>[pathToBinary]);
 }
diff --git a/packages/flutter_tools/lib/src/commands/build_ios_framework.dart b/packages/flutter_tools/lib/src/commands/build_ios_framework.dart
index 2d971b6..675897a 100644
--- a/packages/flutter_tools/lib/src/commands/build_ios_framework.dart
+++ b/packages/flutter_tools/lib/src/commands/build_ios_framework.dart
@@ -342,17 +342,9 @@
     );
     final List<EnvironmentType> environmentTypes = <EnvironmentType>[
       EnvironmentType.physical,
+      EnvironmentType.simulator,
     ];
     final List<Directory> frameworks = <Directory>[];
-    Target target;
-    if (buildInfo.isDebug) {
-      environmentTypes.add(EnvironmentType.simulator);
-      target = const DebugIosApplicationBundle();
-    } else if (buildInfo.isProfile) {
-      target = const ProfileIosApplicationBundle();
-    } else {
-      target = const ReleaseIosApplicationBundle();
-    }
 
     try {
       for (final EnvironmentType sdkType in environmentTypes) {
@@ -392,6 +384,15 @@
               ? null
               : globals.flutterVersion.engineRevision,
         );
+        Target target;
+        // Always build debug for simulator.
+        if (buildInfo.isDebug || sdkType == EnvironmentType.simulator) {
+          target = const DebugIosApplicationBundle();
+        } else if (buildInfo.isProfile) {
+          target = const ProfileIosApplicationBundle();
+        } else {
+          target = const ReleaseIosApplicationBundle();
+        }
         final BuildResult result = await buildSystem.build(target, environment);
         if (!result.success) {
           for (final ExceptionMeasurement measurement
@@ -453,42 +454,42 @@
         throwToolExit('Unable to build plugin frameworks: ${buildPluginsResult.stderr}');
       }
 
-      if (mode == BuildMode.debug) {
-        pluginsBuildCommand = <String>[
-          ...globals.xcode.xcrunCommand(),
-          'xcodebuild',
-          '-alltargets',
-          '-sdk',
-          'iphonesimulator',
-          '-configuration',
-          xcodeBuildConfiguration,
-          'SYMROOT=${simulatorBuildOutput.path}',
-          'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
-          'ARCHS=x86_64',
-          'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
-          'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
-        ];
+      // Always build debug for simulator.
+      final String simulatorConfiguration = toTitleCase(getNameForBuildMode(BuildMode.debug));
+      pluginsBuildCommand = <String>[
+        ...globals.xcode.xcrunCommand(),
+        'xcodebuild',
+        '-alltargets',
+        '-sdk',
+        'iphonesimulator',
+        '-configuration',
+        simulatorConfiguration,
+        'SYMROOT=${simulatorBuildOutput.path}',
+        'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
+        'ARCHS=x86_64',
+        'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
+        'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
+      ];
 
-        buildPluginsResult = await globals.processUtils.run(
-          pluginsBuildCommand,
-          workingDirectory: _project.ios.hostAppRoot
-            .childDirectory('Pods')
-            .path,
-          allowReentrantFlutter: false,
+      buildPluginsResult = await globals.processUtils.run(
+        pluginsBuildCommand,
+        workingDirectory: _project.ios.hostAppRoot
+          .childDirectory('Pods')
+          .path,
+        allowReentrantFlutter: false,
+      );
+
+      if (buildPluginsResult.exitCode != 0) {
+        throwToolExit(
+          'Unable to build plugin frameworks for simulator: ${buildPluginsResult.stderr}',
         );
-
-        if (buildPluginsResult.exitCode != 0) {
-          throwToolExit(
-            'Unable to build plugin frameworks for simulator: ${buildPluginsResult.stderr}',
-          );
-        }
       }
 
       final Directory iPhoneBuildConfiguration = iPhoneBuildOutput.childDirectory(
         '$xcodeBuildConfiguration-iphoneos',
       );
       final Directory simulatorBuildConfiguration = simulatorBuildOutput.childDirectory(
-        '$xcodeBuildConfiguration-iphonesimulator',
+        '$simulatorConfiguration-iphonesimulator',
       );
 
       final Iterable<Directory> products = iPhoneBuildConfiguration
@@ -504,10 +505,9 @@
 
           final List<Directory> frameworks = <Directory>[
             podProduct as Directory,
-            if (mode == BuildMode.debug)
-              simulatorBuildConfiguration
-                  .childDirectory(builtProduct.basename)
-                  .childDirectory(podFrameworkName)
+            simulatorBuildConfiguration
+                .childDirectory(builtProduct.basename)
+                .childDirectory(podFrameworkName)
           ];
 
           await _produceXCFramework(frameworks, binaryName, modeDirectory);