Commit 2065483a authored by Devon Carew's avatar Devon Carew

make --device-id work with ios devices too

parent 12419d6b
...@@ -28,8 +28,6 @@ String findMainDartFile([String target]) { ...@@ -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 { abstract class StartCommandBase extends FlutterCommand {
StartCommandBase() { StartCommandBase() {
argParser.addFlag('checked', argParser.addFlag('checked',
...@@ -51,7 +49,7 @@ abstract class StartCommandBase extends FlutterCommand { ...@@ -51,7 +49,7 @@ abstract class StartCommandBase extends FlutterCommand {
class StartCommand extends StartCommandBase { class StartCommand extends StartCommandBase {
final String name = 'start'; final String name = 'start';
final String description = 'Start your Flutter app on an attached device ' final String description = 'Start your Flutter app on an attached device '
'(defaults to checked/debug mode) (Android only).'; '(defaults to checked/debug mode).';
StartCommand() { StartCommand() {
argParser.addFlag('full-restart', argParser.addFlag('full-restart',
...@@ -139,6 +137,8 @@ Future<int> startApp( ...@@ -139,6 +137,8 @@ Future<int> startApp(
if (clearLogs != null) if (clearLogs != null)
platformArgs['clear-logs'] = clearLogs; platformArgs['clear-logs'] = clearLogs;
printStatus('Starting $mainPath on ${device.name}...');
bool result = await device.startApp( bool result = await device.startApp(
package, package,
toolchain, toolchain,
......
...@@ -131,17 +131,14 @@ class DeviceStore { ...@@ -131,17 +131,14 @@ class DeviceStore {
device = devices.firstWhere( device = devices.firstWhere(
(Device dev) => (dev.id == config.deviceId), (Device dev) => (dev.id == config.deviceId),
orElse: () => null); orElse: () => null);
if (device == null) {
printError('Warning: Device ID ${config.deviceId} not found');
}
} else if (devices.length == 1) { } else if (devices.length == 1) {
// Step 2: If no identifier is specified and there is only one connected // Step 2: If no identifier is specified and there is only one connected
// device, pick that one. // device, pick that one.
device = devices[0]; device = devices[0];
} else if (devices.length > 1) { } else if (devices.length > 1) {
// Step 3: D: // Step 3: D:
printTrace('Multiple devices are connected, but no device ID was specified.'); printStatus('Multiple devices are connected, but no device ID was specified.');
printTrace('Attempting to launch on all connected devices.'); printStatus('Attempting to launch on all connected devices.');
} }
return device; return device;
......
...@@ -42,8 +42,9 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -42,8 +42,9 @@ class FlutterCommandRunner extends CommandRunner {
help: 'The root directory of the Flutter repository. Defaults to \$$kFlutterRootEnvironmentVariableName if set,\n' 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); 'otherwise defaults to a value derived from the location of this tool.', defaultsTo: _defaultFlutterRoot);
argParser.addOption('android-device-id', argParser.addOption('device-id',
help: 'Serial number of the target Android device.'); abbr: 'd',
help: 'Target device id.');
argParser.addSeparator('Local build selection options (not normally required):'); argParser.addSeparator('Local build selection options (not normally required):');
argParser.addFlag('debug', argParser.addFlag('debug',
...@@ -208,7 +209,7 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -208,7 +209,7 @@ class FlutterCommandRunner extends CommandRunner {
configs.add(new BuildConfiguration.prebuilt( configs.add(new BuildConfiguration.prebuilt(
hostPlatform: hostPlatform, hostPlatform: hostPlatform,
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
deviceId: globalResults['android-device-id'] deviceId: globalResults['device-id']
)); ));
if (hostPlatform == HostPlatform.linux) { if (hostPlatform == HostPlatform.linux) {
...@@ -222,12 +223,14 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -222,12 +223,14 @@ class FlutterCommandRunner extends CommandRunner {
if (hostPlatform == HostPlatform.mac) { if (hostPlatform == HostPlatform.mac) {
configs.add(new BuildConfiguration.prebuilt( configs.add(new BuildConfiguration.prebuilt(
hostPlatform: HostPlatform.mac, hostPlatform: HostPlatform.mac,
targetPlatform: TargetPlatform.iOS targetPlatform: TargetPlatform.iOS,
deviceId: globalResults['device-id']
)); ));
configs.add(new BuildConfiguration.prebuilt( configs.add(new BuildConfiguration.prebuilt(
hostPlatform: HostPlatform.mac, hostPlatform: HostPlatform.mac,
targetPlatform: TargetPlatform.iOSSimulator targetPlatform: TargetPlatform.iOSSimulator,
deviceId: globalResults['device-id']
)); ));
} }
} else { } else {
...@@ -244,7 +247,7 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -244,7 +247,7 @@ class FlutterCommandRunner extends CommandRunner {
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
enginePath: enginePath, enginePath: enginePath,
buildPath: globalResults['android-debug-build-path'], buildPath: globalResults['android-debug-build-path'],
deviceId: globalResults['android-device-id'] deviceId: globalResults['device-id']
)); ));
configs.add(new BuildConfiguration.local( configs.add(new BuildConfiguration.local(
...@@ -262,7 +265,8 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -262,7 +265,8 @@ class FlutterCommandRunner extends CommandRunner {
hostPlatform: hostPlatform, hostPlatform: hostPlatform,
targetPlatform: TargetPlatform.iOS, targetPlatform: TargetPlatform.iOS,
enginePath: enginePath, enginePath: enginePath,
buildPath: globalResults['ios-debug-build-path'] buildPath: globalResults['ios-debug-build-path'],
deviceId: globalResults['device-id']
)); ));
configs.add(new BuildConfiguration.local( configs.add(new BuildConfiguration.local(
...@@ -270,7 +274,8 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -270,7 +274,8 @@ class FlutterCommandRunner extends CommandRunner {
hostPlatform: hostPlatform, hostPlatform: hostPlatform,
targetPlatform: TargetPlatform.iOSSimulator, targetPlatform: TargetPlatform.iOSSimulator,
enginePath: enginePath, 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 { ...@@ -282,7 +287,7 @@ class FlutterCommandRunner extends CommandRunner {
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
enginePath: enginePath, enginePath: enginePath,
buildPath: globalResults['android-release-build-path'], buildPath: globalResults['android-release-build-path'],
deviceId: globalResults['android-device-id'] deviceId: globalResults['device-id']
)); ));
configs.add(new BuildConfiguration.local( configs.add(new BuildConfiguration.local(
...@@ -300,7 +305,8 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -300,7 +305,8 @@ class FlutterCommandRunner extends CommandRunner {
hostPlatform: hostPlatform, hostPlatform: hostPlatform,
targetPlatform: TargetPlatform.iOS, targetPlatform: TargetPlatform.iOS,
enginePath: enginePath, enginePath: enginePath,
buildPath: globalResults['ios-release-build-path'] buildPath: globalResults['ios-release-build-path'],
deviceId: globalResults['device-id']
)); ));
configs.add(new BuildConfiguration.local( configs.add(new BuildConfiguration.local(
...@@ -308,7 +314,8 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -308,7 +314,8 @@ class FlutterCommandRunner extends CommandRunner {
hostPlatform: hostPlatform, hostPlatform: hostPlatform,
targetPlatform: TargetPlatform.iOSSimulator, targetPlatform: TargetPlatform.iOSSimulator,
enginePath: enginePath, enginePath: enginePath,
buildPath: globalResults['ios-sim-release-build-path'] buildPath: globalResults['ios-sim-release-build-path'],
deviceId: globalResults['device-id']
)); ));
} }
} }
......
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