Unverified Commit d5225a56 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

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

parent 09cca73a
......@@ -64,6 +64,9 @@ class IOSDevices extends PollingDeviceDiscovery {
'Control of iOS devices or simulators only supported on macOS.'
);
}
if (!_xcdevice.isInstalled) {
return;
}
deviceNotifier ??= ItemListNotifier<Device>();
......@@ -72,7 +75,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');
......
......@@ -370,6 +370,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.getAvailableIOSDevices());
});
testWithoutContext('start polling', () async {
final IOSDevices iosDevices = IOSDevices(
platform: macPlatform,
......
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