From 2065483a1c5f53109f2ac1803b357d0f15d5dc42 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 28 Jan 2016 14:43:57 -0800 Subject: [PATCH] make --device-id work with ios devices too --- .../flutter_tools/lib/src/commands/start.dart | 6 ++-- packages/flutter_tools/lib/src/device.dart | 7 ++--- .../src/runner/flutter_command_runner.dart | 29 ++++++++++++------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/start.dart b/packages/flutter_tools/lib/src/commands/start.dart index 22b7200f35..0cd836f55d 100644 --- a/packages/flutter_tools/lib/src/commands/start.dart +++ b/packages/flutter_tools/lib/src/commands/start.dart @@ -28,8 +28,6 @@ String findMainDartFile([String target]) { } } -// We don't yet support iOS here. https://github.com/flutter/flutter/issues/1036 - abstract class StartCommandBase extends FlutterCommand { StartCommandBase() { argParser.addFlag('checked', @@ -51,7 +49,7 @@ abstract class StartCommandBase extends FlutterCommand { class StartCommand extends StartCommandBase { final String name = 'start'; final String description = 'Start your Flutter app on an attached device ' - '(defaults to checked/debug mode) (Android only).'; + '(defaults to checked/debug mode).'; StartCommand() { argParser.addFlag('full-restart', @@ -139,6 +137,8 @@ Future startApp( if (clearLogs != null) platformArgs['clear-logs'] = clearLogs; + printStatus('Starting $mainPath on ${device.name}...'); + bool result = await device.startApp( package, toolchain, diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 9304553440..b89b786fe8 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -131,17 +131,14 @@ class DeviceStore { device = devices.firstWhere( (Device dev) => (dev.id == config.deviceId), orElse: () => null); - if (device == null) { - printError('Warning: Device ID ${config.deviceId} not found'); - } } else if (devices.length == 1) { // Step 2: If no identifier is specified and there is only one connected // device, pick that one. device = devices[0]; } else if (devices.length > 1) { // Step 3: D: - printTrace('Multiple devices are connected, but no device ID was specified.'); - printTrace('Attempting to launch on all connected devices.'); + printStatus('Multiple devices are connected, but no device ID was specified.'); + printStatus('Attempting to launch on all connected devices.'); } return device; diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index 916e5761ea..0d4b8a716a 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -42,8 +42,9 @@ class FlutterCommandRunner extends CommandRunner { help: 'The root directory of the Flutter repository. Defaults to \$$kFlutterRootEnvironmentVariableName if set,\n' 'otherwise defaults to a value derived from the location of this tool.', defaultsTo: _defaultFlutterRoot); - argParser.addOption('android-device-id', - help: 'Serial number of the target Android device.'); + argParser.addOption('device-id', + abbr: 'd', + help: 'Target device id.'); argParser.addSeparator('Local build selection options (not normally required):'); argParser.addFlag('debug', @@ -208,7 +209,7 @@ class FlutterCommandRunner extends CommandRunner { configs.add(new BuildConfiguration.prebuilt( hostPlatform: hostPlatform, targetPlatform: TargetPlatform.android, - deviceId: globalResults['android-device-id'] + deviceId: globalResults['device-id'] )); if (hostPlatform == HostPlatform.linux) { @@ -222,12 +223,14 @@ class FlutterCommandRunner extends CommandRunner { if (hostPlatform == HostPlatform.mac) { configs.add(new BuildConfiguration.prebuilt( hostPlatform: HostPlatform.mac, - targetPlatform: TargetPlatform.iOS + targetPlatform: TargetPlatform.iOS, + deviceId: globalResults['device-id'] )); configs.add(new BuildConfiguration.prebuilt( hostPlatform: HostPlatform.mac, - targetPlatform: TargetPlatform.iOSSimulator + targetPlatform: TargetPlatform.iOSSimulator, + deviceId: globalResults['device-id'] )); } } else { @@ -244,7 +247,7 @@ class FlutterCommandRunner extends CommandRunner { targetPlatform: TargetPlatform.android, enginePath: enginePath, buildPath: globalResults['android-debug-build-path'], - deviceId: globalResults['android-device-id'] + deviceId: globalResults['device-id'] )); configs.add(new BuildConfiguration.local( @@ -262,7 +265,8 @@ class FlutterCommandRunner extends CommandRunner { hostPlatform: hostPlatform, targetPlatform: TargetPlatform.iOS, enginePath: enginePath, - buildPath: globalResults['ios-debug-build-path'] + buildPath: globalResults['ios-debug-build-path'], + deviceId: globalResults['device-id'] )); configs.add(new BuildConfiguration.local( @@ -270,7 +274,8 @@ class FlutterCommandRunner extends CommandRunner { hostPlatform: hostPlatform, targetPlatform: TargetPlatform.iOSSimulator, enginePath: enginePath, - buildPath: globalResults['ios-sim-debug-build-path'] + buildPath: globalResults['ios-sim-debug-build-path'], + deviceId: globalResults['device-id'] )); } } @@ -282,7 +287,7 @@ class FlutterCommandRunner extends CommandRunner { targetPlatform: TargetPlatform.android, enginePath: enginePath, buildPath: globalResults['android-release-build-path'], - deviceId: globalResults['android-device-id'] + deviceId: globalResults['device-id'] )); configs.add(new BuildConfiguration.local( @@ -300,7 +305,8 @@ class FlutterCommandRunner extends CommandRunner { hostPlatform: hostPlatform, targetPlatform: TargetPlatform.iOS, enginePath: enginePath, - buildPath: globalResults['ios-release-build-path'] + buildPath: globalResults['ios-release-build-path'], + deviceId: globalResults['device-id'] )); configs.add(new BuildConfiguration.local( @@ -308,7 +314,8 @@ class FlutterCommandRunner extends CommandRunner { hostPlatform: hostPlatform, targetPlatform: TargetPlatform.iOSSimulator, enginePath: enginePath, - buildPath: globalResults['ios-sim-release-build-path'] + buildPath: globalResults['ios-sim-release-build-path'], + deviceId: globalResults['device-id'] )); } }