Move XcodeProjectInterpreter to globals (#52847)
This commit is contained in:
parent
e0ab6fc00c
commit
ee845255de
@ -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');
|
||||
|
@ -206,7 +206,7 @@ Future<T> runInContext<T>(
|
||||
processManager: globals.processManager,
|
||||
platform: globals.platform,
|
||||
fileSystem: globals.fs,
|
||||
xcodeProjectInterpreter: xcodeProjectInterpreter,
|
||||
xcodeProjectInterpreter: globals.xcodeProjectInterpreter,
|
||||
),
|
||||
XCDevice: () => XCDevice(
|
||||
processManager: globals.processManager,
|
||||
|
@ -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<IOSWorkflow>();
|
||||
SimControl get simControl => context.get<SimControl>();
|
||||
UserMessages get userMessages => context.get<UserMessages>();
|
||||
Xcode get xcode => context.get<Xcode>();
|
||||
XcodeProjectInterpreter get xcodeProjectInterpreter => context.get<XcodeProjectInterpreter>();
|
||||
|
||||
XCDevice get xcdevice => context.get<XCDevice>();
|
||||
|
||||
|
@ -104,7 +104,7 @@ Future<XcodeBuildResult> 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;
|
||||
|
@ -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<String> _xcodeBuildSettingsLines({
|
||||
return xcodeBuildSettings;
|
||||
}
|
||||
|
||||
XcodeProjectInterpreter get xcodeProjectInterpreter => context.get<XcodeProjectInterpreter>();
|
||||
|
||||
/// Interpreter of Xcode projects.
|
||||
class XcodeProjectInterpreter {
|
||||
XcodeProjectInterpreter({
|
||||
|
@ -52,7 +52,7 @@ Future<void> 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,
|
||||
);
|
||||
|
@ -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<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.
|
||||
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');
|
||||
|
@ -441,11 +441,11 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
|
||||
///
|
||||
/// Returns null, if iOS tooling is unavailable.
|
||||
Future<Map<String, String>> get buildSettings async {
|
||||
if (!xcode.xcodeProjectInterpreter.isInstalled) {
|
||||
if (!globals.xcodeProjectInterpreter.isInstalled) {
|
||||
return null;
|
||||
}
|
||||
Map<String, String> buildSettings = _buildSettings;
|
||||
buildSettings ??= await xcode.xcodeProjectInterpreter.getBuildSettings(
|
||||
buildSettings ??= await globals.xcodeProjectInterpreter.getBuildSettings(
|
||||
xcodeProject.path,
|
||||
_hostAppBundleName,
|
||||
);
|
||||
|
@ -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: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user