Commit 7f3ae43b authored by Eric Seidel's avatar Eric Seidel

Make `flutter list` not crash on linux.

Turns out linux does have an ideviceinstaller package
however it doesn't contain idevice_id or any of the
other tools we use.  Furthermore we don't have
xcrun or the rest of xcode on linux so we can't
manipulate simulators either.

No sense in printing out a warning that ios isn't supported
every time on linux, so I wrapped that block in osx only.

@chinmaygarde @devoncarew
parent caf5b7ea
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import '../android/device_android.dart'; import '../android/device_android.dart';
import '../ios/device_ios.dart'; import '../ios/device_ios.dart';
...@@ -43,25 +44,27 @@ class ListCommand extends FlutterCommand { ...@@ -43,25 +44,27 @@ class ListCommand extends FlutterCommand {
} }
} }
if (details) if (Platform.isMacOS) {
print('iOS Devices:'); if (details)
print('iOS Devices:');
for (IOSDevice device in IOSDevice.getAttachedDevices(devices.iOS)) { for (IOSDevice device in IOSDevice.getAttachedDevices(devices.iOS)) {
if (details) { if (details) {
print('${device.id}\t${device.name}'); print('${device.id}\t${device.name}');
} else { } else {
print(device.id); print(device.id);
}
} }
}
if (details) if (details)
print('iOS Simulators:'); print('iOS Simulators:');
for (IOSSimulator device in IOSSimulator.getAttachedDevices(devices.iOSSimulator)) { for (IOSSimulator device in IOSSimulator.getAttachedDevices(devices.iOSSimulator)) {
if (details) { if (details) {
print('${device.id}\t${device.name}'); print('${device.id}\t${device.name}');
} else { } else {
print(device.id); print(device.id);
}
} }
} }
......
...@@ -21,10 +21,6 @@ class IOSDevice extends Device { ...@@ -21,10 +21,6 @@ class IOSDevice extends Device {
'To work with iOS devices, please install ideviceinstaller. ' 'To work with iOS devices, please install ideviceinstaller. '
'If you use homebrew, you can install it with ' 'If you use homebrew, you can install it with '
'"\$ brew install ideviceinstaller".'; '"\$ brew install ideviceinstaller".';
static const String _linuxInstructions =
'To work with iOS devices, please install ideviceinstaller. '
'On Ubuntu or Debian, you can install it with '
'"\$ apt-get install ideviceinstaller".';
String _installerPath; String _installerPath;
String get installerPath => _installerPath; String get installerPath => _installerPath;
...@@ -100,19 +96,16 @@ class IOSDevice extends Device { ...@@ -100,19 +96,16 @@ class IOSDevice extends Device {
static final Map<String, String> _commandMap = {}; static final Map<String, String> _commandMap = {};
static String _checkForCommand( static String _checkForCommand(
String command, [ String command, [
String macInstructions = _macInstructions, String macInstructions = _macInstructions
String linuxInstructions = _linuxInstructions
]) { ]) {
return _commandMap.putIfAbsent(command, () { return _commandMap.putIfAbsent(command, () {
try { try {
command = runCheckedSync(['which', command]).trim(); command = runCheckedSync(['which', command]).trim();
} catch (e) { } catch (e) {
if (Platform.isMacOS) { if (Platform.isMacOS) {
logging.severe(macInstructions); logging.severe('$command not found. $macInstructions');
} else if (Platform.isLinux) {
logging.severe(linuxInstructions);
} else { } else {
logging.severe('$command is not available on your platform.'); logging.severe('Cannot control iOS devices or simulators. $command is not available on your platform.');
} }
} }
return command; return command;
...@@ -331,9 +324,12 @@ class IOSSimulator extends Device { ...@@ -331,9 +324,12 @@ class IOSSimulator extends Device {
static List<IOSSimulator> getAttachedDevices([IOSSimulator mockIOS]) { static List<IOSSimulator> getAttachedDevices([IOSSimulator mockIOS]) {
List<IOSSimulator> devices = []; List<IOSSimulator> devices = [];
_IOSSimulatorInfo deviceInfo = _getRunningSimulatorInfo(mockIOS); try {
if (deviceInfo != null) _IOSSimulatorInfo deviceInfo = _getRunningSimulatorInfo(mockIOS);
devices.add(new IOSSimulator(id: deviceInfo.id, name: deviceInfo.name)); if (deviceInfo != null)
devices.add(new IOSSimulator(id: deviceInfo.id, name: deviceInfo.name));
} catch (e) {
}
return devices; return devices;
} }
......
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