From e788bb09be1d5089de7b0b489b253e406a34d1c8 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Fri, 5 Feb 2021 03:51:26 -0800 Subject: [PATCH] Add logs support for physical devices Summary: There's a bit of an oddity with `idb` that the `stream` parameter is implied even though the docs say otherwise and if you try to use it, it'll give you a strange Python error. That's likely why we never implemented it. Now, it works just as it does using local tooling. Reviewed By: mweststrate Differential Revision: D26228036 fbshipit-source-id: e20cb31167170ba0501e2929ed129305cb9aaf2c --- desktop/app/src/devices/IOSDevice.tsx | 51 ++++++++++++++++----------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/desktop/app/src/devices/IOSDevice.tsx b/desktop/app/src/devices/IOSDevice.tsx index 3bca24843..4fa9b9e51 100644 --- a/desktop/app/src/devices/IOSDevice.tsx +++ b/desktop/app/src/devices/IOSDevice.tsx @@ -79,9 +79,6 @@ export default class IOSDevice extends BaseDevice { } startLogListener(retries: number = 3) { - if (this.deviceType === 'physical') { - return; - } if (retries === 0) { console.warn('Attaching iOS log listener continuously failed.'); return; @@ -91,24 +88,36 @@ export default class IOSDevice extends BaseDevice { ? ['--set', process.env.DEVICE_SET_PATH] : []; - this.log = child_process.spawn( - 'xcrun', - [ - 'simctl', - ...deviceSetPath, - 'spawn', - this.serial, - 'log', - 'stream', - '--style', - 'json', - '--predicate', - 'senderImagePath contains "Containers"', - '--info', - '--debug', - ], - {}, - ); + const extraArgs = [ + '--style', + 'json', + '--predicate', + 'senderImagePath contains "Containers"', + '--debug', + '--info', + ]; + + if (this.deviceType === 'physical') { + this.log = child_process.spawn( + 'idb', + ['log', '--udid', this.serial, '--', ...extraArgs], + {}, + ); + } else { + this.log = child_process.spawn( + 'xcrun', + [ + 'simctl', + ...deviceSetPath, + 'spawn', + this.serial, + 'log', + 'stream', + ...extraArgs, + ], + {}, + ); + } this.log.on('error', (err: Error) => { console.error('iOS log tailer error', err);