From 7f3ae43b7f586d4f02ec5da121afec4a331eb411 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Fri, 22 Jan 2016 14:50:03 -0800 Subject: [PATCH] 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 --- .../flutter_tools/lib/src/commands/list.dart | 33 ++++++++++--------- .../flutter_tools/lib/src/ios/device_ios.dart | 22 +++++-------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/list.dart b/packages/flutter_tools/lib/src/commands/list.dart index f2f1feafefe..2cc77c66863 100644 --- a/packages/flutter_tools/lib/src/commands/list.dart +++ b/packages/flutter_tools/lib/src/commands/list.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io'; import '../android/device_android.dart'; import '../ios/device_ios.dart'; @@ -43,25 +44,27 @@ class ListCommand extends FlutterCommand { } } - if (details) - print('iOS Devices:'); + if (Platform.isMacOS) { + if (details) + print('iOS Devices:'); - for (IOSDevice device in IOSDevice.getAttachedDevices(devices.iOS)) { - if (details) { - print('${device.id}\t${device.name}'); - } else { - print(device.id); + for (IOSDevice device in IOSDevice.getAttachedDevices(devices.iOS)) { + if (details) { + print('${device.id}\t${device.name}'); + } else { + print(device.id); + } } - } - if (details) - print('iOS Simulators:'); + if (details) + print('iOS Simulators:'); - for (IOSSimulator device in IOSSimulator.getAttachedDevices(devices.iOSSimulator)) { - if (details) { - print('${device.id}\t${device.name}'); - } else { - print(device.id); + for (IOSSimulator device in IOSSimulator.getAttachedDevices(devices.iOSSimulator)) { + if (details) { + print('${device.id}\t${device.name}'); + } else { + print(device.id); + } } } diff --git a/packages/flutter_tools/lib/src/ios/device_ios.dart b/packages/flutter_tools/lib/src/ios/device_ios.dart index 7c1b19f67ad..34aadbe0a30 100644 --- a/packages/flutter_tools/lib/src/ios/device_ios.dart +++ b/packages/flutter_tools/lib/src/ios/device_ios.dart @@ -21,10 +21,6 @@ class IOSDevice extends Device { 'To work with iOS devices, please install ideviceinstaller. ' 'If you use homebrew, you can install it with ' '"\$ 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 get installerPath => _installerPath; @@ -100,19 +96,16 @@ class IOSDevice extends Device { static final Map _commandMap = {}; static String _checkForCommand( String command, [ - String macInstructions = _macInstructions, - String linuxInstructions = _linuxInstructions + String macInstructions = _macInstructions ]) { return _commandMap.putIfAbsent(command, () { try { command = runCheckedSync(['which', command]).trim(); } catch (e) { if (Platform.isMacOS) { - logging.severe(macInstructions); - } else if (Platform.isLinux) { - logging.severe(linuxInstructions); + logging.severe('$command not found. $macInstructions'); } 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; @@ -331,9 +324,12 @@ class IOSSimulator extends Device { static List getAttachedDevices([IOSSimulator mockIOS]) { List devices = []; - _IOSSimulatorInfo deviceInfo = _getRunningSimulatorInfo(mockIOS); - if (deviceInfo != null) - devices.add(new IOSSimulator(id: deviceInfo.id, name: deviceInfo.name)); + try { + _IOSSimulatorInfo deviceInfo = _getRunningSimulatorInfo(mockIOS); + if (deviceInfo != null) + devices.add(new IOSSimulator(id: deviceInfo.id, name: deviceInfo.name)); + } catch (e) { + } return devices; }