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