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
This commit is contained in:
Pascal Hartig
2021-02-05 03:51:26 -08:00
committed by Facebook GitHub Bot
parent 05acdc99b0
commit e788bb09be

View File

@@ -79,9 +79,6 @@ export default class IOSDevice extends BaseDevice {
} }
startLogListener(retries: number = 3) { startLogListener(retries: number = 3) {
if (this.deviceType === 'physical') {
return;
}
if (retries === 0) { if (retries === 0) {
console.warn('Attaching iOS log listener continuously failed.'); console.warn('Attaching iOS log listener continuously failed.');
return; return;
@@ -91,24 +88,36 @@ export default class IOSDevice extends BaseDevice {
? ['--set', process.env.DEVICE_SET_PATH] ? ['--set', process.env.DEVICE_SET_PATH]
: []; : [];
this.log = child_process.spawn( const extraArgs = [
'xcrun', '--style',
[ 'json',
'simctl', '--predicate',
...deviceSetPath, 'senderImagePath contains "Containers"',
'spawn', '--debug',
this.serial, '--info',
'log', ];
'stream',
'--style', if (this.deviceType === 'physical') {
'json', this.log = child_process.spawn(
'--predicate', 'idb',
'senderImagePath contains "Containers"', ['log', '--udid', this.serial, '--', ...extraArgs],
'--info', {},
'--debug', );
], } else {
{}, this.log = child_process.spawn(
); 'xcrun',
[
'simctl',
...deviceSetPath,
'spawn',
this.serial,
'log',
'stream',
...extraArgs,
],
{},
);
}
this.log.on('error', (err: Error) => { this.log.on('error', (err: Error) => {
console.error('iOS log tailer error', err); console.error('iOS log tailer error', err);