[flutter_tools] Remove context from Xcode and most of Xcodeproj (#48661)

diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
index b3c7f74..4f3873b 100644
--- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart
+++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
@@ -5,6 +5,8 @@
 import 'dart:async';
 
 import 'package:meta/meta.dart';
+import 'package:platform/platform.dart';
+import 'package:process/process.dart';
 
 import '../artifacts.dart';
 import '../base/common.dart';
@@ -14,6 +16,7 @@
 import '../base/logger.dart';
 import '../base/os.dart';
 import '../base/process.dart';
+import '../base/terminal.dart';
 import '../base/utils.dart';
 import '../build_info.dart';
 import '../cache.dart';
@@ -221,15 +224,33 @@
 
 /// Interpreter of Xcode projects.
 class XcodeProjectInterpreter {
+  XcodeProjectInterpreter({
+    @required Platform platform,
+    @required ProcessManager processManager,
+    @required Logger logger,
+    @required FileSystem fileSystem,
+    @required AnsiTerminal terminal,
+  }) : _platform = platform,
+       _fileSystem = fileSystem,
+       _terminal = terminal,
+       _logger = logger,
+       _processUtils = ProcessUtils(logger: logger, processManager: processManager);
+
+  final Platform _platform;
+  final FileSystem _fileSystem;
+  final ProcessUtils _processUtils;
+  final AnsiTerminal _terminal;
+  final Logger _logger;
+
   static const String _executable = '/usr/bin/xcodebuild';
   static final RegExp _versionRegex = RegExp(r'Xcode ([0-9.]+)');
 
   void _updateVersion() {
-    if (!globals.platform.isMacOS || !globals.fs.file(_executable).existsSync()) {
+    if (!_platform.isMacOS || !_fileSystem.file(_executable).existsSync()) {
       return;
     }
     try {
-      final RunResult result = processUtils.runSync(
+      final RunResult result = _processUtils.runSync(
         <String>[_executable, '-version'],
       );
       if (result.exitCode != 0) {
@@ -283,26 +304,26 @@
     Duration timeout = const Duration(minutes: 1),
   }) async {
     final Status status = Status.withSpinner(
-      timeout: timeoutConfiguration.fastOperation,
-      timeoutConfiguration: timeoutConfiguration,
-      platform: globals.platform,
+      timeout: const TimeoutConfiguration().fastOperation,
+      timeoutConfiguration: const TimeoutConfiguration(),
+      platform: _platform,
       stopwatch: Stopwatch(),
-      supportsColor: globals.terminal.supportsColor,
+      supportsColor: _terminal.supportsColor,
     );
     final List<String> showBuildSettingsCommand = <String>[
       _executable,
       '-project',
-      globals.fs.path.absolute(projectPath),
+      _fileSystem.path.absolute(projectPath),
       '-target',
       target,
       '-showBuildSettings',
-      ...environmentVariablesAsXcodeBuildSettings()
+      ...environmentVariablesAsXcodeBuildSettings(_platform)
     ];
     try {
       // showBuildSettings is reported to occasionally timeout. Here, we give it
       // a lot of wiggle room (locally on Flutter Gallery, this takes ~1s).
       // When there is a timeout, we retry once.
-      final RunResult result = await processUtils.run(
+      final RunResult result = await _processUtils.run(
         showBuildSettingsCommand,
         throwOnError: true,
         workingDirectory: projectPath,
@@ -317,7 +338,7 @@
           command: showBuildSettingsCommand.join(' '),
         ).send();
       }
-      globals.printTrace('Unexpected failure to get the build settings: $error.');
+      _logger.printTrace('Unexpected failure to get the build settings: $error.');
       return const <String, String>{};
     } finally {
       status.stop();
@@ -325,7 +346,7 @@
   }
 
   void cleanWorkspace(String workspacePath, String scheme) {
-    processUtils.runSync(<String>[
+    _processUtils.runSync(<String>[
       _executable,
       '-workspace',
       workspacePath,
@@ -333,8 +354,8 @@
       scheme,
       '-quiet',
       'clean',
-      ...environmentVariablesAsXcodeBuildSettings()
-    ], workingDirectory: globals.fs.currentDirectory.path);
+      ...environmentVariablesAsXcodeBuildSettings(_platform)
+    ], workingDirectory: _fileSystem.currentDirectory.path);
   }
 
   Future<XcodeProjectInfo> getInfo(String projectPath, {String projectFilename}) async {
@@ -342,7 +363,7 @@
     // * -project is passed and the given project isn't there, or
     // * no -project is passed and there isn't a project.
     const int missingProjectExitCode = 66;
-    final RunResult result = await processUtils.run(
+    final RunResult result = await _processUtils.run(
       <String>[
         _executable,
         '-list',
@@ -363,9 +384,9 @@
 /// This allows developers to pass arbitrary build settings in without the tool needing to make a flag
 /// for or be aware of each one. This could be used to set code signing build settings in a CI
 /// environment without requiring settings changes in the Xcode project.
-List<String> environmentVariablesAsXcodeBuildSettings() {
+List<String> environmentVariablesAsXcodeBuildSettings(Platform platform) {
   const String xcodeBuildSettingPrefix = 'FLUTTER_XCODE_';
-  return globals.platform.environment.entries.where((MapEntry<String, String> mapEntry) {
+  return platform.environment.entries.where((MapEntry<String, String> mapEntry) {
     return mapEntry.key.startsWith(xcodeBuildSettingPrefix);
   }).expand<String>((MapEntry<String, String> mapEntry) {
     // Remove FLUTTER_XCODE_ prefix from the environment variable to get the build setting.