[flutter_releases] Flutter stable 2.5.2 Framework Cherrypicks (#91047)

* Set BUILD_DIR when determining if plugins support arm64 simulators (#90088)

* 'Update Engine revision to 6ac856380fa4f66469552ce986edf59f65f7cd68 for stable release 2.5.2'

Co-authored-by: Jenn Magder <magder@google.com>
diff --git a/bin/internal/engine.version b/bin/internal/engine.version
index 819e163..cb14ebd 100644
--- a/bin/internal/engine.version
+++ b/bin/internal/engine.version
@@ -1 +1 @@
-b3af521a050e6ef076778bcaf16e27b2521df8f8
+6ac856380fa4f66469552ce986edf59f65f7cd68
diff --git a/dev/devicelab/bin/tasks/plugin_lint_mac.dart b/dev/devicelab/bin/tasks/plugin_lint_mac.dart
index 37aadaf..b92f422 100644
--- a/dev/devicelab/bin/tasks/plugin_lint_mac.dart
+++ b/dev/devicelab/bin/tasks/plugin_lint_mac.dart
@@ -499,6 +499,13 @@
     'test_plugin_swift',
     'ios',
   ));
+
+  // Make sure no Xcode build settings are leaking derived data/build directory into the ios directory.
+  checkDirectoryNotExists(path.join(
+    appPath,
+    'ios',
+    'build',
+  ));
 }
 
 void _validateMacOSPodfile(String appPath) {
diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
index 2e5d4bc..780093f 100644
--- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart
+++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
@@ -227,6 +227,7 @@
       return null;
     }
     final Status status = _logger.startSpinner();
+    final String buildDirectory = _fileSystem.path.absolute(getIosBuildDirectory());
     final List<String> showBuildSettingsCommand = <String>[
       ...xcrunCommand(),
       'xcodebuild',
@@ -236,6 +237,8 @@
       '-project',
       podXcodeProject.path,
       '-showBuildSettings',
+      'BUILD_DIR=$buildDirectory',
+      'OBJROOT=$buildDirectory',
     ];
     try {
       // showBuildSettings is reported to occasionally timeout. Here, we give it
diff --git a/packages/flutter_tools/templates/app_shared/ios.tmpl/.gitignore b/packages/flutter_tools/templates/app_shared/ios.tmpl/.gitignore
index 151026b..7a7f987 100644
--- a/packages/flutter_tools/templates/app_shared/ios.tmpl/.gitignore
+++ b/packages/flutter_tools/templates/app_shared/ios.tmpl/.gitignore
@@ -1,3 +1,4 @@
+**/dgph
 *.mode1v3
 *.mode2v3
 *.moved-aside
diff --git a/packages/flutter_tools/templates/app_shared/macos.tmpl/.gitignore b/packages/flutter_tools/templates/app_shared/macos.tmpl/.gitignore
index d2fd377..746adbb 100644
--- a/packages/flutter_tools/templates/app_shared/macos.tmpl/.gitignore
+++ b/packages/flutter_tools/templates/app_shared/macos.tmpl/.gitignore
@@ -3,4 +3,5 @@
 **/Pods/
 
 # Xcode-related
+**/dgph
 **/xcuserdata/
diff --git a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
index 275fc9a..52f478e 100644
--- a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
@@ -695,6 +695,7 @@
         final Directory podXcodeProject = project.ios.hostAppRoot.childDirectory('Pods').childDirectory('Pods.xcodeproj')
           ..createSync(recursive: true);
 
+        final String buildDirectory = fileSystem.path.absolute('build', 'ios');
         fakeProcessManager.addCommands(<FakeCommand>[
           kWhichSysctlCommand,
           kARMCheckCommand,
@@ -710,6 +711,8 @@
               '-project',
               podXcodeProject.path,
               '-showBuildSettings',
+              'BUILD_DIR=$buildDirectory',
+              'OBJROOT=$buildDirectory',
             ],
             stdout: '''
 Build settings for action build and target plugin1:
@@ -748,6 +751,7 @@
         final Directory podXcodeProject = project.ios.hostAppRoot.childDirectory('Pods').childDirectory('Pods.xcodeproj')
           ..createSync(recursive: true);
 
+        final String buildDirectory = fileSystem.path.absolute('build', 'ios');
         fakeProcessManager.addCommands(<FakeCommand>[
           kWhichSysctlCommand,
           kARMCheckCommand,
@@ -763,6 +767,8 @@
                 '-project',
                 podXcodeProject.path,
                 '-showBuildSettings',
+                'BUILD_DIR=$buildDirectory',
+                'OBJROOT=$buildDirectory',
               ],
               exitCode: 1,
           ),
@@ -789,6 +795,7 @@
         final Directory podXcodeProject = project.ios.hostAppRoot.childDirectory('Pods').childDirectory('Pods.xcodeproj')
           ..createSync(recursive: true);
 
+        final String buildDirectory = fileSystem.path.absolute('build', 'ios');
         fakeProcessManager.addCommands(<FakeCommand>[
           kWhichSysctlCommand,
           kARMCheckCommand,
@@ -804,6 +811,8 @@
                 '-project',
                 podXcodeProject.path,
                 '-showBuildSettings',
+                'BUILD_DIR=$buildDirectory',
+                'OBJROOT=$buildDirectory',
               ],
               stdout: '''
 Build settings for action build and target plugin1: