( simulatorUuid: string, bundleId: string, executor: CommandExecutor, )
| 280 | } |
| 281 | |
| 282 | async function resolveAppPidViaLaunch( |
| 283 | simulatorUuid: string, |
| 284 | bundleId: string, |
| 285 | executor: CommandExecutor, |
| 286 | ): Promise<number | undefined> { |
| 287 | // simctl launch is idempotent: calling it on an already-running app |
| 288 | // returns the existing PID without relaunching. |
| 289 | const result = await executor( |
| 290 | ['xcrun', 'simctl', 'launch', simulatorUuid, bundleId], |
| 291 | 'Resolve App PID', |
| 292 | false, |
| 293 | ); |
| 294 | if (!result.success) { |
| 295 | log('warn', `Failed to resolve app PID: ${result.error ?? result.output}`); |
| 296 | return undefined; |
| 297 | } |
| 298 | const pidMatch = result.output?.match(/:\s*(\d+)\s*$/); |
| 299 | return pidMatch ? parseInt(pidMatch[1], 10) : undefined; |
| 300 | } |
| 301 | |
| 302 | function stopDetachedHelper(child: ChildProcess): void { |
| 303 | try { |
no test coverage detected