Unverified Commit ee845255 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Move XcodeProjectInterpreter to globals (#52847)

parent e0ab6fc0
...@@ -67,9 +67,9 @@ class CleanCommand extends FlutterCommand { ...@@ -67,9 +67,9 @@ class CleanCommand extends FlutterCommand {
); );
try { try {
final Directory xcodeWorkspace = xcodeProject.xcodeWorkspace; 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) { for (final String scheme in projectInfo.schemes) {
await xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme); await globals.xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme);
} }
} on Exception catch (error) { } on Exception catch (error) {
globals.printTrace('Could not clean Xcode workspace: $error'); globals.printTrace('Could not clean Xcode workspace: $error');
......
...@@ -206,7 +206,7 @@ Future<T> runInContext<T>( ...@@ -206,7 +206,7 @@ Future<T> runInContext<T>(
processManager: globals.processManager, processManager: globals.processManager,
platform: globals.platform, platform: globals.platform,
fileSystem: globals.fs, fileSystem: globals.fs,
xcodeProjectInterpreter: xcodeProjectInterpreter, xcodeProjectInterpreter: globals.xcodeProjectInterpreter,
), ),
XCDevice: () => XCDevice( XCDevice: () => XCDevice(
processManager: globals.processManager, processManager: globals.processManager,
......
...@@ -27,6 +27,7 @@ import 'ios/ios_workflow.dart'; ...@@ -27,6 +27,7 @@ import 'ios/ios_workflow.dart';
import 'ios/mac.dart'; import 'ios/mac.dart';
import 'ios/plist_parser.dart'; import 'ios/plist_parser.dart';
import 'ios/simulators.dart'; import 'ios/simulators.dart';
import 'ios/xcodeproj.dart';
import 'macos/xcode.dart'; import 'macos/xcode.dart';
import 'persistent_tool_state.dart'; import 'persistent_tool_state.dart';
import 'reporting/reporting.dart'; import 'reporting/reporting.dart';
...@@ -78,6 +79,7 @@ IOSWorkflow get iosWorkflow => context.get<IOSWorkflow>(); ...@@ -78,6 +79,7 @@ IOSWorkflow get iosWorkflow => context.get<IOSWorkflow>();
SimControl get simControl => context.get<SimControl>(); SimControl get simControl => context.get<SimControl>();
UserMessages get userMessages => context.get<UserMessages>(); UserMessages get userMessages => context.get<UserMessages>();
Xcode get xcode => context.get<Xcode>(); Xcode get xcode => context.get<Xcode>();
XcodeProjectInterpreter get xcodeProjectInterpreter => context.get<XcodeProjectInterpreter>();
XCDevice get xcdevice => context.get<XCDevice>(); XCDevice get xcdevice => context.get<XCDevice>();
......
...@@ -104,7 +104,7 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -104,7 +104,7 @@ Future<XcodeBuildResult> buildXcodeProject({
return XcodeBuildResult(success: false); 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')) { if (!projectInfo.targets.contains('Runner')) {
globals.printError('The Xcode project does not define target "Runner" which is needed by Flutter tooling.'); globals.printError('The Xcode project does not define target "Runner" which is needed by Flutter tooling.');
globals.printError('Open Xcode to fix the problem:'); globals.printError('Open Xcode to fix the problem:');
...@@ -545,12 +545,12 @@ bool _checkXcodeVersion() { ...@@ -545,12 +545,12 @@ bool _checkXcodeVersion() {
if (!globals.platform.isMacOS) { if (!globals.platform.isMacOS) {
return false; return false;
} }
if (!xcodeProjectInterpreter.isInstalled) { if (!globals.xcodeProjectInterpreter.isInstalled) {
globals.printError('Cannot find "xcodebuild". $_xcodeRequirement'); globals.printError('Cannot find "xcodebuild". $_xcodeRequirement');
return false; return false;
} }
if (!globals.xcode.isVersionSatisfactory) { if (!globals.xcode.isVersionSatisfactory) {
globals.printError('Found "${xcodeProjectInterpreter.versionText}". $_xcodeRequirement'); globals.printError('Found "${globals.xcodeProjectInterpreter.versionText}". $_xcodeRequirement');
return false; return false;
} }
return true; return true;
......
...@@ -10,7 +10,6 @@ import 'package:process/process.dart'; ...@@ -10,7 +10,6 @@ import 'package:process/process.dart';
import '../artifacts.dart'; import '../artifacts.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
...@@ -243,8 +242,6 @@ List<String> _xcodeBuildSettingsLines({ ...@@ -243,8 +242,6 @@ List<String> _xcodeBuildSettingsLines({
return xcodeBuildSettings; return xcodeBuildSettings;
} }
XcodeProjectInterpreter get xcodeProjectInterpreter => context.get<XcodeProjectInterpreter>();
/// Interpreter of Xcode projects. /// Interpreter of Xcode projects.
class XcodeProjectInterpreter { class XcodeProjectInterpreter {
XcodeProjectInterpreter({ XcodeProjectInterpreter({
......
...@@ -52,7 +52,7 @@ Future<void> buildMacOS({ ...@@ -52,7 +52,7 @@ Future<void> buildMacOS({
// other Xcode projects in the macos/ directory. Otherwise pass no name, which will work // 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. // regardless of the project name so long as there is exactly one project.
final String xcodeProjectName = xcodeProject.existsSync() ? xcodeProject.basename : null; final String xcodeProjectName = xcodeProject.existsSync() ? xcodeProject.basename : null;
final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo( final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter.getInfo(
xcodeProject.parent.path, xcodeProject.parent.path,
projectFilename: xcodeProjectName, projectFilename: xcodeProjectName,
); );
......
...@@ -16,7 +16,6 @@ import '../base/process.dart'; ...@@ -16,7 +16,6 @@ import '../base/process.dart';
import '../base/version.dart'; import '../base/version.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../ios/xcodeproj.dart';
import '../project.dart'; import '../project.dart';
const String noCocoaPodsConsequence = ''' const String noCocoaPodsConsequence = '''
...@@ -225,7 +224,7 @@ class CocoaPods { ...@@ -225,7 +224,7 @@ class CocoaPods {
/// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files /// contains a suitable `Podfile` and that its `Flutter/Xxx.xcconfig` files
/// include pods configuration. /// include pods configuration.
Future<void> setupPodfile(XcodeBasedProject xcodeProject) async { Future<void> setupPodfile(XcodeBasedProject xcodeProject) async {
if (!xcodeProjectInterpreter.isInstalled) { if (!globals.xcodeProjectInterpreter.isInstalled) {
// Don't do anything for iOS when host platform doesn't support it. // Don't do anything for iOS when host platform doesn't support it.
return; return;
} }
...@@ -242,7 +241,7 @@ class CocoaPods { ...@@ -242,7 +241,7 @@ class CocoaPods {
if (xcodeProject is MacOSProject) { if (xcodeProject is MacOSProject) {
podfileTemplateName = 'Podfile-macos'; podfileTemplateName = 'Podfile-macos';
} else { } else {
final bool isSwift = (await xcodeProjectInterpreter.getBuildSettings( final bool isSwift = (await globals.xcodeProjectInterpreter.getBuildSettings(
runnerProject.path, runnerProject.path,
'Runner', 'Runner',
)).containsKey('SWIFT_VERSION'); )).containsKey('SWIFT_VERSION');
......
...@@ -441,11 +441,11 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject { ...@@ -441,11 +441,11 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
/// ///
/// Returns null, if iOS tooling is unavailable. /// Returns null, if iOS tooling is unavailable.
Future<Map<String, String>> get buildSettings async { Future<Map<String, String>> get buildSettings async {
if (!xcode.xcodeProjectInterpreter.isInstalled) { if (!globals.xcodeProjectInterpreter.isInstalled) {
return null; return null;
} }
Map<String, String> buildSettings = _buildSettings; Map<String, String> buildSettings = _buildSettings;
buildSettings ??= await xcode.xcodeProjectInterpreter.getBuildSettings( buildSettings ??= await globals.xcodeProjectInterpreter.getBuildSettings(
xcodeProject.path, xcodeProject.path,
_hostAppBundleName, _hostAppBundleName,
); );
......
...@@ -72,7 +72,7 @@ void main() { ...@@ -72,7 +72,7 @@ void main() {
expect(projectUnderTest.macos.ephemeralDirectory.existsSync(), isFalse); expect(projectUnderTest.macos.ephemeralDirectory.existsSync(), isFalse);
expect(projectUnderTest.windows.ephemeralDirectory.existsSync(), isFalse); expect(projectUnderTest.windows.ephemeralDirectory.existsSync(), isFalse);
verify(xcodeProjectInterpreter.cleanWorkspace(any, 'Runner')).called(2); verify(mockXcodeProjectInterpreter.cleanWorkspace(any, 'Runner')).called(2);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment