Skip to content

Commit 8af6b2f

Browse files
Patrick Sosinskijmagman
andauthored
1.17.5 CP: Fix daemon device discovery crash when Xcode isn't installed (#60546) (#60611)
* Fix daemon device discovery crash when Xcode isn't installed (#60546) * getAvailableIOSDevices -> getAvailableTetheredIOSDevices Co-authored-by: Jenn Magder <[email protected]>
1 parent 1ad9baa commit 8af6b2f

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎packages/flutter_tools/lib/src/ios/devices.dart‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class IOSDevices extends PollingDeviceDiscovery {
6969
'Control of iOS devices or simulators only supported on macOS.'
7070
);
7171
}
72+
if (!_xcdevice.isInstalled) {
73+
return;
74+
}
7275

7376
deviceNotifier ??= ItemListNotifier<Device>();
7477

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

7881
// cancel any outstanding subscriptions.
7982
await _observedDeviceEventsSubscription?.cancel();
80-
_observedDeviceEventsSubscription = _xcdevice.observedDeviceEvents().listen(
83+
_observedDeviceEventsSubscription = _xcdevice.observedDeviceEvents()?.listen(
8184
_onDeviceEvent,
8285
onError: (dynamic error, StackTrace stack) {
8386
_logger.printTrace('Process exception running xcdevice observe:\n$error\n$stack');

‎packages/flutter_tools/test/general.shard/ios/devices_test.dart‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,19 @@ void main() {
318318
);
319319
});
320320

321+
testWithoutContext('start polling without Xcode', () async {
322+
final IOSDevices iosDevices = IOSDevices(
323+
platform: macPlatform,
324+
xcdevice: mockXcdevice,
325+
iosWorkflow: mockIosWorkflow,
326+
logger: logger,
327+
);
328+
when(mockXcdevice.isInstalled).thenReturn(false);
329+
330+
await iosDevices.startPolling();
331+
verifyNever(mockXcdevice.getAvailableTetheredIOSDevices());
332+
});
333+
321334
testWithoutContext('start polling', () async {
322335
final IOSDevices iosDevices = IOSDevices(
323336
platform: macPlatform,

0 commit comments

Comments
 (0)