Commit bb0a6757 authored by Dan Rubel's avatar Dan Rubel Committed by GitHub

Suggest simulator when no devices (#5770)

When flutter run is used on a Mac and no devices are specified or attached, suggest launching a simulator first. Fixes https://github.com/flutter/flutter/issues/5674
parent 5bc8888e
......@@ -13,6 +13,7 @@ import '../cache.dart';
import '../device.dart';
import '../globals.dart';
import '../hot.dart';
import '../ios/mac.dart';
import '../vmservice.dart';
import '../resident_runner.dart';
import '../run.dart';
......@@ -98,6 +99,18 @@ class RunCommand extends RunCommandBase {
return '$command/${getNameForTargetPlatform(device.platform)}';
}
@override
void printNoConnectedDevices() {
super.printNoConnectedDevices();
if (getCurrentHostPlatform() == HostPlatform.darwin_x64 &&
XCode.instance.isInstalledAndMeetsVersionCheck) {
printStatus('');
printStatus('To run on a simulator, launch it first:');
printStatus('open -a Simulator.app');
printStatus('');
}
}
@override
Future<int> runInProject() async {
int debugPort;
......
......@@ -141,7 +141,7 @@ abstract class FlutterCommand extends Command {
"matching '${deviceManager.specifiedDeviceId}'");
return 1;
} else if (devices.isEmpty) {
printStatus('No connected devices.');
printNoConnectedDevices();
return 1;
}
......@@ -192,6 +192,10 @@ abstract class FlutterCommand extends Command {
return await runInProject();
}
void printNoConnectedDevices() {
printStatus('No connected devices.');
}
// This is a field so that you can modify the value for testing.
Validator commandValidator;
......
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