Skip to content

Commit

Permalink
1.17.5 CP: Fix daemon device discovery crash when Xcode isn't install…
Browse files Browse the repository at this point in the history
…ed (#60546) (#60611)

* Fix daemon device discovery crash when Xcode isn't installed (#60546)

* getAvailableIOSDevices -> getAvailableTetheredIOSDevices

Co-authored-by: Jenn Magder <magder@google.com>
  • Loading branch information
Patrick Sosinski and jmagman committed Jun 30, 2020
1 parent 1ad9baa commit 8af6b2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/flutter_tools/lib/src/ios/devices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class IOSDevices extends PollingDeviceDiscovery {
'Control of iOS devices or simulators only supported on macOS.'
);
}
if (!_xcdevice.isInstalled) {
return;
}

deviceNotifier ??= ItemListNotifier<Device>();

Expand All @@ -77,7 +80,7 @@ class IOSDevices extends PollingDeviceDiscovery {

// cancel any outstanding subscriptions.
await _observedDeviceEventsSubscription?.cancel();
_observedDeviceEventsSubscription = _xcdevice.observedDeviceEvents().listen(
_observedDeviceEventsSubscription = _xcdevice.observedDeviceEvents()?.listen(
_onDeviceEvent,
onError: (dynamic error, StackTrace stack) {
_logger.printTrace('Process exception running xcdevice observe:\n$error\n$stack');
Expand Down
13 changes: 13 additions & 0 deletions packages/flutter_tools/test/general.shard/ios/devices_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,19 @@ void main() {
);
});

testWithoutContext('start polling without Xcode', () async {
final IOSDevices iosDevices = IOSDevices(
platform: macPlatform,
xcdevice: mockXcdevice,
iosWorkflow: mockIosWorkflow,
logger: logger,
);
when(mockXcdevice.isInstalled).thenReturn(false);

await iosDevices.startPolling();
verifyNever(mockXcdevice.getAvailableTetheredIOSDevices());
});

testWithoutContext('start polling', () async {
final IOSDevices iosDevices = IOSDevices(
platform: macPlatform,
Expand Down

0 comments on commit 8af6b2f

Please sign in to comment.