diff --git a/packages/flutter_tools/lib/src/commands/clean.dart b/packages/flutter_tools/lib/src/commands/clean.dart index a352261df4..6c23d4576f 100644 --- a/packages/flutter_tools/lib/src/commands/clean.dart +++ b/packages/flutter_tools/lib/src/commands/clean.dart @@ -67,9 +67,9 @@ class CleanCommand extends FlutterCommand { ); try { final Directory xcodeWorkspace = xcodeProject.xcodeWorkspace; - final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path); + final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path); for (final String scheme in projectInfo.schemes) { - await xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme); + await globals.xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme); } } on Exception catch (error) { globals.printTrace('Could not clean Xcode workspace: $error'); diff --git a/packages/flutter_tools/lib/src/context_runner.dart b/packages/flutter_tools/lib/src/context_runner.dart index 4611bf7d75..07ad8c8a03 100644 --- a/packages/flutter_tools/lib/src/context_runner.dart +++ b/packages/flutter_tools/lib/src/context_runner.dart @@ -206,7 +206,7 @@ Future runInContext( processManager: globals.processManager, platform: globals.platform, fileSystem: globals.fs, - xcodeProjectInterpreter: xcodeProjectInterpreter, + xcodeProjectInterpreter: globals.xcodeProjectInterpreter, ), XCDevice: () => XCDevice( processManager: globals.processManager, diff --git a/packages/flutter_tools/lib/src/globals.dart b/packages/flutter_tools/lib/src/globals.dart index 2c8f3edeb3..2d325aa198 100644 --- a/packages/flutter_tools/lib/src/globals.dart +++ b/packages/flutter_tools/lib/src/globals.dart @@ -27,6 +27,7 @@ import 'ios/ios_workflow.dart'; import 'ios/mac.dart'; import 'ios/plist_parser.dart'; import 'ios/simulators.dart'; +import 'ios/xcodeproj.dart'; import 'macos/xcode.dart'; import 'persistent_tool_state.dart'; import 'reporting/reporting.dart'; @@ -78,6 +79,7 @@ IOSWorkflow get iosWorkflow => context.get(); SimControl get simControl => context.get(); UserMessages get userMessages => context.get(); Xcode get xcode => context.get(); +XcodeProjectInterpreter get xcodeProjectInterpreter => context.get(); XCDevice get xcdevice => context.get(); diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 82e09df39c..f506acdeea 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -104,7 +104,7 @@ Future buildXcodeProject({ return XcodeBuildResult(success: false); } - final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(app.project.hostAppRoot.path); + final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter.getInfo(app.project.hostAppRoot.path); if (!projectInfo.targets.contains('Runner')) { globals.printError('The Xcode project does not define target "Runner" which is needed by Flutter tooling.'); globals.printError('Open Xcode to fix the problem:'); @@ -545,12 +545,12 @@ bool _checkXcodeVersion() { if (!globals.platform.isMacOS) { return false; } - if (!xcodeProjectInterpreter.isInstalled) { + if (!globals.xcodeProjectInterpreter.isInstalled) { globals.printError('Cannot find "xcodebuild". $_xcodeRequirement'); return false; } if (!globals.xcode.isVersionSatisfactory) { - globals.printError('Found "${xcodeProjectInterpreter.versionText}". $_xcodeRequirement'); + globals.printError('Found "${globals.xcodeProjectInterpreter.versionText}". $_xcodeRequirement'); return false; } return true; diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 978fc5c23e..30ce20d651 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -10,7 +10,6 @@ import 'package:process/process.dart'; import '../artifacts.dart'; import '../base/common.dart'; -import '../base/context.dart'; import '../base/file_system.dart'; import '../base/io.dart'; import '../base/logger.dart'; @@ -243,8 +242,6 @@ List _xcodeBuildSettingsLines({ return xcodeBuildSettings; } -XcodeProjectInterpreter get xcodeProjectInterpreter => context.get(); - /// Interpreter of Xcode projects. class XcodeProjectInterpreter { XcodeProjectInterpreter({ diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart index b2db86d4a5..6f7cb3e566 100644 --- a/packages/flutter_tools/lib/src/macos/build_macos.dart +++ b/packages/flutter_tools/lib/src/macos/build_macos.dart @@ -52,7 +52,7 @@ Future buildMacOS({ // other Xcode projects in the macos/ directory. Otherwise pass no name, which will work // regardless of the project name so long as there is exactly one project. final String xcodeProjectName = xcodeProject.existsSync() ? xcodeProject.basename : null; - final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo( + final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter.getInfo( xcodeProject.parent.path, projectFilename: xcodeProjectName, ); diff --git a/packages/flutter_tools/lib/src/macos/cocoapods.dart b/packages/flutter_tools/lib/src/macos/cocoapods.dart index 121e846fb9..fd3e516668 100644 --- a/packages/flutter_tools/lib/src/macos/cocoapods.dart +++ b/packages/flutter_tools/lib/src/macos/cocoapods.dart @@ -16,7 +16,6 @@ import '../base/process.dart'; import '../base/version.dart'; import '../cache.dart'; import '../globals.dart' as globals; -import '../ios/xcodeproj.dart'; import '../project.dart'; const String noCocoaPodsConsequence = ''' @@ -225,7 +224,7 @@ class CocoaPods { /// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files /// include pods configuration. Future setupPodfile(XcodeBasedProject xcodeProject) async { - if (!xcodeProjectInterpreter.isInstalled) { + if (!globals.xcodeProjectInterpreter.isInstalled) { // Don't do anything for iOS when host platform doesn't support it. return; } @@ -242,7 +241,7 @@ class CocoaPods { if (xcodeProject is MacOSProject) { podfileTemplateName = 'Podfile-macos'; } else { - final bool isSwift = (await xcodeProjectInterpreter.getBuildSettings( + final bool isSwift = (await globals.xcodeProjectInterpreter.getBuildSettings( runnerProject.path, 'Runner', )).containsKey('SWIFT_VERSION'); diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 6da9674e86..9bd80fa412 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -441,11 +441,11 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject { /// /// Returns null, if iOS tooling is unavailable. Future> get buildSettings async { - if (!xcode.xcodeProjectInterpreter.isInstalled) { + if (!globals.xcodeProjectInterpreter.isInstalled) { return null; } Map buildSettings = _buildSettings; - buildSettings ??= await xcode.xcodeProjectInterpreter.getBuildSettings( + buildSettings ??= await globals.xcodeProjectInterpreter.getBuildSettings( xcodeProject.path, _hostAppBundleName, ); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart index 766af14444..aeaabf56db 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart @@ -72,7 +72,7 @@ void main() { expect(projectUnderTest.macos.ephemeralDirectory.existsSync(), isFalse); expect(projectUnderTest.windows.ephemeralDirectory.existsSync(), isFalse); - verify(xcodeProjectInterpreter.cleanWorkspace(any, 'Runner')).called(2); + verify(mockXcodeProjectInterpreter.cleanWorkspace(any, 'Runner')).called(2); }, overrides: { FileSystem: () => fs, ProcessManager: () => FakeProcessManager.any(),