launch_app
Launch apps on iOS Simulator using bundle identifiers to test and interact with applications in simulated environments.
Instructions
Launches an app on the iOS Simulator by bundle identifier
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| udid | No | Udid of target, can also be set with the IDB_UDID env var | |
| bundle_id | Yes | Bundle identifier of the app to launch (e.g., com.apple.mobilesafari) | |
| terminate_running | No | Terminate the app if it is already running before launching |
Implementation Reference
- src/index.ts:956-999 (handler)The handler function that executes the launch_app tool. It resolves the device UDID if not provided, runs 'xcrun simctl launch' with optional terminate flag, extracts the PID from output, and returns success or error response.async ({ udid, bundle_id, terminate_running }) => { try { const actualUdid = await getBootedDeviceId(udid); // run() will throw if the command fails (non-zero exit code) const { stdout } = await run("xcrun", [ "simctl", "launch", ...(terminate_running ? ["--terminate-running-process"] : []), actualUdid, bundle_id, ]); // Extract PID from output if available // simctl launch outputs the PID as the first token in stdout const pidMatch = stdout.match(/^(\d+)/); const pid = pidMatch ? pidMatch[1] : null; return { isError: false, content: [ { type: "text", text: pid ? `App ${bundle_id} launched successfully with PID: ${pid}` : `App ${bundle_id} launched successfully`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error launching app: ${toError(error).message}` ), }, ], }; } } );
- src/index.ts:937-955 (schema)Zod schema defining the input parameters for the launch_app tool: udid (optional), bundle_id (required), terminate_running (optional).{ udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), bundle_id: z .string() .max(256) .describe( "Bundle identifier of the app to launch (e.g., com.apple.mobilesafari)" ), terminate_running: z .boolean() .optional() .describe( "Terminate the app if it is already running before launching" ), },
- src/index.ts:933-1000 (registration)The server.tool call that registers the launch_app tool, including schema and handler, guarded by isToolFiltered check.if (!isToolFiltered("launch_app")) { server.tool( "launch_app", "Launches an app on the iOS Simulator by bundle identifier", { udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), bundle_id: z .string() .max(256) .describe( "Bundle identifier of the app to launch (e.g., com.apple.mobilesafari)" ), terminate_running: z .boolean() .optional() .describe( "Terminate the app if it is already running before launching" ), }, async ({ udid, bundle_id, terminate_running }) => { try { const actualUdid = await getBootedDeviceId(udid); // run() will throw if the command fails (non-zero exit code) const { stdout } = await run("xcrun", [ "simctl", "launch", ...(terminate_running ? ["--terminate-running-process"] : []), actualUdid, bundle_id, ]); // Extract PID from output if available // simctl launch outputs the PID as the first token in stdout const pidMatch = stdout.match(/^(\d+)/); const pid = pidMatch ? pidMatch[1] : null; return { isError: false, content: [ { type: "text", text: pid ? `App ${bundle_id} launched successfully with PID: ${pid}` : `App ${bundle_id} launched successfully`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error launching app: ${toError(error).message}` ), }, ], }; } } ); }