|
1 | | -import { spawn } from '@react-native-harness/tools'; |
| 1 | +import { spawn, spawnAndForget } from '@react-native-harness/tools'; |
2 | 2 | import { reloadApp } from '../../bundlers/metro.js'; |
3 | 3 |
|
4 | 4 | export const listDevices = async (): Promise<any> => { |
@@ -33,8 +33,9 @@ export const installPods = async (): Promise<void> => { |
33 | 33 | }; |
34 | 34 |
|
35 | 35 | export const listApps = async (udid: string): Promise<string[]> => { |
36 | | - const { stdout } = await spawn('xcrun', ['simctl', 'listapps', udid]); |
37 | | - return stdout.split('\n').map((line) => line.trim()); |
| 36 | + const { stdout: plistOutput } = await spawn('xcrun', ['simctl', 'listapps', udid]); |
| 37 | + const { stdout: jsonOutput } = await spawn('plutil', ['-convert', 'json', '-o', '-', '-'], { stdin: { string: plistOutput } }); |
| 38 | + return Object.keys(JSON.parse(jsonOutput)); |
38 | 39 | }; |
39 | 40 |
|
40 | 41 | export const isAppInstalled = async ( |
@@ -66,13 +67,13 @@ export const runApp = async ( |
66 | 67 | simulatorName: string, |
67 | 68 | appName: string |
68 | 69 | ): Promise<void> => { |
69 | | - await spawn('xcrun', ['simctl', 'terminate', simulatorName, appName]); |
| 70 | + await killApp(simulatorName, appName); |
70 | 71 | await spawn('xcrun', ['simctl', 'launch', simulatorName, appName]); |
71 | 72 | }; |
72 | 73 |
|
73 | 74 | export const killApp = async ( |
74 | 75 | simulatorName: string, |
75 | 76 | appName: string |
76 | 77 | ): Promise<void> => { |
77 | | - await spawn('xcrun', ['simctl', 'terminate', simulatorName, appName]); |
| 78 | + await spawnAndForget('xcrun', ['simctl', 'terminate', simulatorName, appName]); |
78 | 79 | }; |
0 commit comments