build_ios_sim_id_ws
Build an iOS app for a specific simulator using its UUID by providing a workspace path, scheme, and simulator ID. Supports custom configurations, derived data paths, and additional xcodebuild arguments.
Instructions
Builds an iOS app from a workspace for a specific simulator by UUID. IMPORTANT: Requires workspacePath, scheme, and simulatorId. Example: build_ios_sim_id_ws({ workspacePath: '/path/to/MyProject.xcworkspace', scheme: 'MyScheme', simulatorId: 'SIMULATOR_UUID' })
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| configuration | No | Build configuration (Debug, Release, etc.) | |
| derivedDataPath | No | Path where build products and other derived data will go | |
| extraArgs | No | Additional xcodebuild arguments | |
| preferXcodebuild | No | If true, prefers xcodebuild over the experimental incremental build system, useful for when incremental build system fails. | |
| scheme | Yes | The scheme to use (Required) | |
| simulatorId | Yes | UUID of the simulator to use (obtained from listSimulators) (Required) | |
| useLatestOS | No | Whether to use the latest OS version for the named simulator | |
| workspacePath | Yes | Path to the .xcworkspace file (Required) |
Implementation Reference
- src/tools/build_ios_simulator.ts:42-70 (handler)Core handler logic for executing the iOS simulator build. Validates parameters indirectly through caller and invokes executeXcodeBuildCommand with platform set to iOSSimulator.async function _handleIOSSimulatorBuildLogic(params: { workspacePath?: string; projectPath?: string; scheme: string; configuration: string; simulatorName?: string; simulatorId?: string; useLatestOS: boolean; derivedDataPath?: string; extraArgs?: string[]; preferXcodebuild?: boolean; }): Promise<ToolResponse> { log('info', `Starting iOS Simulator build for scheme ${params.scheme} (internal)`); return executeXcodeBuildCommand( { ...params, }, { platform: XcodePlatform.iOSSimulator, simulatorName: params.simulatorName, simulatorId: params.simulatorId, useLatestOS: params.useLatestOS, logPrefix: 'iOS Simulator Build', }, params.preferXcodebuild, 'build', ); }
- src/tools/build_ios_simulator.ts:458-506 (registration)Tool module registration function that calls registerTool to add 'build_ios_sim_id_ws' to the MCP server with description, input schema, and inline handler performing validation and delegating to _handleIOSSimulatorBuildLogic.* Registers the iOS Simulator build by ID workspace tool */ export function registerIOSSimulatorBuildByIdWorkspaceTool(server: McpServer): void { type Params = { workspacePath: string; scheme: string; simulatorId: string; configuration?: string; derivedDataPath?: string; extraArgs?: string[]; useLatestOS?: boolean; preferXcodebuild?: boolean; }; registerTool<Params>( server, 'build_ios_sim_id_ws', "Builds an iOS app from a workspace for a specific simulator by UUID. IMPORTANT: Requires workspacePath, scheme, and simulatorId. Example: build_ios_sim_id_ws({ workspacePath: '/path/to/MyProject.xcworkspace', scheme: 'MyScheme', simulatorId: 'SIMULATOR_UUID' })", { workspacePath: workspacePathSchema, scheme: schemeSchema, simulatorId: simulatorIdSchema, configuration: configurationSchema, derivedDataPath: derivedDataPathSchema, extraArgs: extraArgsSchema, useLatestOS: useLatestOSSchema, preferXcodebuild: preferXcodebuildSchema, }, async (params: Params) => { // Validate required parameters const workspaceValidation = validateRequiredParam('workspacePath', params.workspacePath); if (!workspaceValidation.isValid) return workspaceValidation.errorResponse!; const schemeValidation = validateRequiredParam('scheme', params.scheme); if (!schemeValidation.isValid) return schemeValidation.errorResponse!; const simulatorIdValidation = validateRequiredParam('simulatorId', params.simulatorId); if (!simulatorIdValidation.isValid) return simulatorIdValidation.errorResponse!; // Provide defaults return _handleIOSSimulatorBuildLogic({ ...params, configuration: params.configuration ?? 'Debug', useLatestOS: params.useLatestOS ?? true, // May be ignored by xcodebuild preferXcodebuild: params.preferXcodebuild ?? false, }); }, ); }
- src/utils/register-tools.ts:227-230 (registration)Top-level server registration: includes the tool's module register function in toolRegistrations array, which is processed by registerTools(server) to conditionally register based on env var.register: registerIOSSimulatorBuildByIdWorkspaceTool, groups: [ToolGroup.IOS_SIMULATOR_WORKFLOW], envVar: 'XCODEBUILDMCP_TOOL_IOS_SIMULATOR_BUILD_BY_ID_WORKSPACE', },
- src/tools/common.ts:22-62 (schema)Zod schemas for common tool parameters used in the build_ios_sim_id_ws tool, including workspacePathSchema, schemeSchema, simulatorIdSchema, configurationSchema, and others.export const workspacePathSchema = z.string().describe('Path to the .xcworkspace file (Required)'); export const projectPathSchema = z.string().describe('Path to the .xcodeproj file (Required)'); export const schemeSchema = z.string().describe('The scheme to use (Required)'); export const configurationSchema = z .string() .optional() .describe('Build configuration (Debug, Release, etc.)'); export const derivedDataPathSchema = z .string() .optional() .describe('Path where build products and other derived data will go'); export const extraArgsSchema = z .array(z.string()) .optional() .describe('Additional xcodebuild arguments'); export const simulatorNameSchema = z .string() .describe("Name of the simulator to use (e.g., 'iPhone 16') (Required)"); export const simulatorIdSchema = z .string() .describe('UUID of the simulator to use (obtained from listSimulators) (Required)'); export const useLatestOSSchema = z .boolean() .optional() .describe('Whether to use the latest OS version for the named simulator'); export const appPathSchema = z .string() .describe('Path to the .app bundle (full path to the .app directory)'); export const bundleIdSchema = z .string() .describe("Bundle identifier of the app (e.g., 'com.example.MyApp')"); export const launchArgsSchema = z .array(z.string()) .optional() .describe('Additional arguments to pass to the app'); export const preferXcodebuildSchema = z .boolean() .optional() .describe( 'If true, prefers xcodebuild over the experimental incremental build system, useful for when incremental build system fails.', );
- src/tools/common.ts:160-179 (helper)Utility function registerTool used to register all MCP tools, wrapping the handler to match MCP server.tool signature.export function registerTool<T extends object>( server: McpServer, name: string, description: string, schema: Record<string, z.ZodType>, handler: (params: T) => Promise<ToolResponse>, ): void { // Create a wrapper handler that matches the signature expected by server.tool const wrappedHandler = ( args: Record<string, unknown>, _extra: unknown, ): Promise<ToolResponse> => { // Assert the type *before* calling the original handler // This confines the type assertion to one place const typedParams = args as T; return handler(typedParams); }; server.tool(name, description, schema, wrappedHandler); }