(
simulatorId: string,
bundleId: string,
executor: CommandExecutor,
opts?: { args?: string[]; env?: Record<string, string> },
)
| 118 | * Launch an app on a simulator and return the process ID if available. |
| 119 | */ |
| 120 | export async function launchSimulatorApp( |
| 121 | simulatorId: string, |
| 122 | bundleId: string, |
| 123 | executor: CommandExecutor, |
| 124 | opts?: { args?: string[]; env?: Record<string, string> }, |
| 125 | ): Promise<LaunchStepResult> { |
| 126 | log('info', `Launching app with bundle ID: ${bundleId} on simulator: ${simulatorId}`); |
| 127 | const command = ['xcrun', 'simctl', 'launch', simulatorId, bundleId]; |
| 128 | if (opts?.args?.length) { |
| 129 | command.push(...opts.args); |
| 130 | } |
| 131 | |
| 132 | const execOpts = opts?.env ? { env: normalizeSimctlChildEnv(opts.env) } : undefined; |
| 133 | const result = await executor(command, 'Launch App', false, execOpts); |
| 134 | if (!result.success) { |
| 135 | return { success: false, error: result.error ?? 'Failed to launch app' }; |
| 136 | } |
| 137 | |
| 138 | const pidMatch = result.output?.match(/:\s*(\d+)\s*$/); |
| 139 | const processId = pidMatch ? parseInt(pidMatch[1], 10) : undefined; |
| 140 | return { success: true, processId }; |
| 141 | } |
| 142 | |
| 143 | export type ProcessSpawner = ( |
| 144 | command: string, |
nothing calls this directly
no test coverage detected