Refactor Xcode instance lookup (#10763)
Use a top-level getter in mac.dart rather than a static instance getter
and a top-level getter in ios_workflow.dart. Makes this code consistent
with how we do context lookups elsewhere.
diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
index 9f6e0de..35ee3ba 100644
--- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart
+++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
@@ -16,8 +16,6 @@
IOSWorkflow get iosWorkflow => context.putIfAbsent(IOSWorkflow, () => new IOSWorkflow());
-Xcode get xcode => Xcode.instance;
-
class IOSWorkflow extends DoctorValidator implements Workflow {
IOSWorkflow() : super('iOS toolchain - develop for iOS devices');
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart
index 5e2337a..a646650 100644
--- a/packages/flutter_tools/lib/src/ios/mac.dart
+++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -35,6 +35,8 @@
IMobileDevice get iMobileDevice => context.putIfAbsent(IMobileDevice, () => const IMobileDevice());
+Xcode get xcode => context.putIfAbsent(Xcode, () => new Xcode());
+
class PythonModule {
const PythonModule(this.name);
@@ -120,9 +122,6 @@
}
}
- /// Returns [Xcode] active in the current app context.
- static Xcode get instance => context.putIfAbsent(Xcode, () => new Xcode());
-
bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory;
String _xcodeSelectPath;
diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart
index e5f37ac..5a57b38 100644
--- a/packages/flutter_tools/lib/src/ios/simulators.dart
+++ b/packages/flutter_tools/lib/src/ios/simulators.dart
@@ -45,7 +45,7 @@
static IOSSimulatorUtils get instance => context[IOSSimulatorUtils];
List<IOSSimulator> getAttachedDevices() {
- if (!Xcode.instance.isInstalledAndMeetsVersionCheck)
+ if (!xcode.isInstalledAndMeetsVersionCheck)
return <IOSSimulator>[];
return SimControl.instance.getConnectedDevices().map((SimDevice device) {
@@ -587,8 +587,7 @@
}
bool get _xcodeVersionSupportsScreenshot {
- return Xcode.instance.xcodeMajorVersion > 8 ||
- (Xcode.instance.xcodeMajorVersion == 8 && Xcode.instance.xcodeMinorVersion >= 2);
+ return xcode.xcodeMajorVersion > 8 || (xcode.xcodeMajorVersion == 8 && xcode.xcodeMinorVersion >= 2);
}
@override