ios_boot_simulator
Start an iOS simulator for testing and development by providing its unique device identifier. This tool enables developers to launch virtual iOS devices for app testing.
Instructions
Boot an iOS simulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| udid | Yes | Simulator UDID |
Implementation Reference
- src/tools/ios.ts:330-365 (handler)Executes the ios_boot_simulator tool: validates input with Zod schema, checks macOS platform, validates UDID format, runs 'xcrun simctl boot' with timeout, handles already-booted case (exit 164), returns structured success response.handler: async (args: any) => { checkMacOS(); const validation = IosSimulatorActionSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { udid } = validation.data; // Validate UDID format if (!validateUDID(udid)) { throw new Error(`Invalid simulator UDID format. UDID must be in format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX: ${udid}`); } const result = await processExecutor.execute('xcrun', ['simctl', 'boot', udid], { timeout: 60000, // 1 minute timeout for simulator boot }); // Note: simctl boot returns exit code 164 if simulator is already booted, which is not an error if (result.exitCode !== 0 && result.exitCode !== 164) { throw new Error(`Failed to boot iOS simulator: ${result.stderr}`); } const isAlreadyBooted = result.exitCode === 164; return { success: true, data: { udid, status: isAlreadyBooted ? 'already_booted' : 'booted', message: isAlreadyBooted ? 'Simulator was already booted' : 'Simulator booted successfully', output: result.stdout, }, }; }
- src/tools/ios.ts:320-366 (registration)Registers the ios_boot_simulator tool in the tools Map returned by createIOSTools(), defining name, description, JSON inputSchema, and inline handler function.tools.set('ios_boot_simulator', { name: 'ios_boot_simulator', description: 'Boot an iOS simulator', inputSchema: { type: 'object', properties: { udid: { type: 'string', minLength: 1, description: 'Simulator UDID' } }, required: ['udid'] }, handler: async (args: any) => { checkMacOS(); const validation = IosSimulatorActionSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { udid } = validation.data; // Validate UDID format if (!validateUDID(udid)) { throw new Error(`Invalid simulator UDID format. UDID must be in format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX: ${udid}`); } const result = await processExecutor.execute('xcrun', ['simctl', 'boot', udid], { timeout: 60000, // 1 minute timeout for simulator boot }); // Note: simctl boot returns exit code 164 if simulator is already booted, which is not an error if (result.exitCode !== 0 && result.exitCode !== 164) { throw new Error(`Failed to boot iOS simulator: ${result.stderr}`); } const isAlreadyBooted = result.exitCode === 164; return { success: true, data: { udid, status: isAlreadyBooted ? 'already_booted' : 'booted', message: isAlreadyBooted ? 'Simulator was already booted' : 'Simulator booted successfully', output: result.stdout, }, }; } });
- src/tools/ios.ts:52-54 (schema)Zod validation schema used by ios_boot_simulator (and similar tools) to validate required 'udid' input parameter.const IosSimulatorActionSchema = z.object({ udid: z.string().min(1), });
- src/tools/ios.ts:159-162 (helper)Helper function to validate iOS simulator UDID format (UUID v4 pattern), called in the handler.const validateUDID = (udid: string): boolean => { const uuidPattern = /^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/i; return uuidPattern.test(udid); };
- src/tools/ios.ts:140-144 (helper)Helper function to enforce macOS platform requirement, called at start of handler.const checkMacOS = (): void => { if (process.platform !== 'darwin') { throw new Error(`iOS development tools only work on macOS. Current platform: ${process.platform}`); } };