Support physical device logging

Summary:
Changelog: Logs plugin now supports physical iOS devices

As reported in https://github.com/facebook/flipper/issues/262 and linked papercut.

This diff adds support for iOS device logs through idb. Since idb doesn't respect `--json` flag at the moment, we perform the parsing in Flipper itself.

Reviewed By: passy

Differential Revision: D27346262

fbshipit-source-id: 3b314716f48bb9a7fe709370303396a51893359c
This commit is contained in:
Michel Weststrate
2021-03-29 06:59:15 -07:00
committed by Facebook GitHub Bot
parent d22e893169
commit d5fbe9a5b9
9 changed files with 170 additions and 45 deletions

View File

@@ -18,7 +18,7 @@ test('uses xcrun with no idb when xcode is detected', async () => {
const ib = await makeIOSBridge('', true);
expect(ib.startLogListener).toBeDefined();
ib.startLogListener!('deadbeef');
ib.startLogListener!('deadbeef', 'emulator');
expect(spawn).toHaveBeenCalledWith(
'xcrun',
@@ -43,7 +43,7 @@ test('uses idb when present and xcode detected', async () => {
const ib = await makeIOSBridge('/usr/local/bin/idb', true, async (_) => true);
expect(ib.startLogListener).toBeDefined();
ib.startLogListener!('deadbeef');
ib.startLogListener!('deadbeef', 'emulator');
expect(spawn).toHaveBeenCalledWith(
'/usr/local/bin/idb',
@@ -63,6 +63,31 @@ test('uses idb when present and xcode detected', async () => {
);
});
test('uses idb when present and xcode detected and physical device connected', async () => {
const ib = await makeIOSBridge('/usr/local/bin/idb', true, async (_) => true);
expect(ib.startLogListener).toBeDefined();
ib.startLogListener!('deadbeef', 'physical');
expect(spawn).toHaveBeenCalledWith(
'/usr/local/bin/idb',
[
'log',
'--udid',
'deadbeef',
'--',
// no further args; not supported by idb atm
],
{},
);
});
test("without idb physical devices can't log", async () => {
const ib = await makeIOSBridge('', true);
expect(ib.idbAvailable).toBeFalsy();
expect(ib.startLogListener).toBeDefined(); // since we have xcode
});
test('uses no log listener when xcode is not detected', async () => {
const ib = await makeIOSBridge('', false);
expect(ib.startLogListener).toBeUndefined();