Commit 0fb288c5 authored by Devon Carew's avatar Devon Carew

refactor to move an ios specific class out of globals.dart

parent 59664e4f
......@@ -32,7 +32,6 @@ import 'src/commands/update_packages.dart';
import 'src/commands/upgrade.dart';
import 'src/device.dart';
import 'src/doctor.dart';
import 'src/ios/mac.dart';
import 'src/runner/flutter_command_runner.dart';
/// Main entry point for commands.
......@@ -69,7 +68,6 @@ Future main(List<String> args) async {
context[Logger] = new StdoutLogger();
context[DeviceManager] = new DeviceManager();
Doctor.initGlobal();
XCode.initGlobal();
dynamic result = await runner.run(args);
......
......@@ -7,16 +7,12 @@ import 'base/context.dart';
import 'base/logger.dart';
import 'device.dart';
import 'doctor.dart';
import 'ios/mac.dart';
DeviceManager get deviceManager => context[DeviceManager];
Logger get logger => context[Logger];
AndroidSdk get androidSdk => context[AndroidSdk];
Doctor get doctor => context[Doctor];
// Mac specific globals - will be null on other platforms.
XCode get xcode => context[XCode];
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
void printError(String message, [StackTrace stackTrace]) => logger.printError(message, stackTrace);
......
......@@ -6,7 +6,6 @@ import 'dart:io';
import '../base/process.dart';
import '../doctor.dart';
import '../globals.dart';
import 'mac.dart';
class IOSWorkflow extends Workflow {
......@@ -15,11 +14,11 @@ class IOSWorkflow extends Workflow {
bool get appliesToHostPlatform => Platform.isMacOS;
// We need xcode (+simctl) to list simulator devices, and idevice_id to list real devices.
bool get canListDevices => xcode.isInstalledAndMeetsVersionCheck;
bool get canListDevices => XCode.instance.isInstalledAndMeetsVersionCheck;
// We need xcode to launch simulator devices, and ideviceinstaller and ios-deploy
// for real devices.
bool get canLaunchDevices => xcode.isInstalledAndMeetsVersionCheck;
bool get canLaunchDevices => XCode.instance.isInstalledAndMeetsVersionCheck;
ValidationResult validate() {
Validator iosValidator = new Validator(
......@@ -28,15 +27,15 @@ class IOSWorkflow extends Workflow {
);
ValidationType xcodeExists() {
return xcode.isInstalled ? ValidationType.installed : ValidationType.missing;
return XCode.instance.isInstalled ? ValidationType.installed : ValidationType.missing;
};
ValidationType xcodeVersionSatisfactory() {
return xcode.isInstalledAndMeetsVersionCheck ? ValidationType.installed : ValidationType.missing;
return XCode.instance.isInstalledAndMeetsVersionCheck ? ValidationType.installed : ValidationType.missing;
};
ValidationType xcodeEulaSigned() {
return xcode.eulaSigned ? ValidationType.installed : ValidationType.missing;
return XCode.instance.eulaSigned ? ValidationType.installed : ValidationType.missing;
};
ValidationType brewExists() {
......
......@@ -18,15 +18,12 @@ import 'setup_xcodeproj.dart';
String get homeDirectory => path.absolute(Platform.environment['HOME']);
// TODO(devoncarew): Refactor functionality into XCode.
const int kXcodeRequiredVersionMajor = 7;
const int kXcodeRequiredVersionMinor = 2;
class XCode {
static void initGlobal() {
context[XCode] = new XCode();
}
/// Returns [XCode] active in the current app context.
static XCode get instance => context[XCode] ?? (context[XCode] = new XCode());
bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory;
......
......@@ -38,7 +38,7 @@ class IOSSimulatorUtils {
}
List<IOSSimulator> getAttachedDevices() {
if (!xcode.isInstalledAndMeetsVersionCheck)
if (!XCode.instance.isInstalledAndMeetsVersionCheck)
return <IOSSimulator>[];
return SimControl.instance.getConnectedDevices().map((SimDevice device) {
......@@ -320,7 +320,7 @@ class IOSSimulator extends Device {
if (clearLogs)
this.clearLogs();
if(!(await _setupUpdatedApplicationBundle(app, toolchain)))
if (!(await _setupUpdatedApplicationBundle(app, toolchain)))
return false;
// Prepare launch arguments.
......
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