build_sim_id_proj
Build an app from a project file for a specific simulator by UUID using projectPath, scheme, and simulatorId. Supports build configuration, derived data path, and additional xcodebuild arguments.
Instructions
Builds an app from a project file for a specific simulator by UUID. IMPORTANT: Requires projectPath, scheme, and simulatorId. Example: build_sim_id_proj({ projectPath: '/path/to/MyProject.xcodeproj', 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. | |
| projectPath | Yes | Path to the .xcodeproj file (Required) | |
| scheme | Yes | The scheme to use (Required) | |
| simulatorId | Yes | UUID of the simulator to use (obtained from listSimulators) (Required) | |
| simulatorName | No | Name of the simulator (optional) | |
| useLatestOS | No | Whether to use the latest OS version for the named simulator |
Implementation Reference
- The core logic function (build_simLogic) that processes parameters and calls the simulator build handler. This executes the tool's main functionality using simulatorId or simulatorName with project/workspace path.export async function build_simLogic( params: BuildSimulatorParams, executor: CommandExecutor, ): Promise<ToolResponse> { // Provide defaults const processedParams: BuildSimulatorParams = { ...params, configuration: params.configuration ?? 'Debug', useLatestOS: params.useLatestOS ?? true, // May be ignored if simulatorId is provided preferXcodebuild: params.preferXcodebuild ?? false, }; return _handleSimulatorBuildLogic(processedParams, executor); }
- Zod schema (buildSimulatorSchema) defining input parameters including projectPath/workspacePath and simulatorId/simulatorName (mutually exclusive pairs), with refinements for validation.const buildSimulatorSchema = baseSchema .refine((val) => val.projectPath !== undefined || val.workspacePath !== undefined, { message: 'Either projectPath or workspacePath is required.', }) .refine((val) => !(val.projectPath !== undefined && val.workspacePath !== undefined), { message: 'projectPath and workspacePath are mutually exclusive. Provide only one.', }) .refine((val) => val.simulatorId !== undefined || val.simulatorName !== undefined, { message: 'Either simulatorId or simulatorName is required.', }) .refine((val) => !(val.simulatorId !== undefined && val.simulatorName !== undefined), { message: 'simulatorId and simulatorName are mutually exclusive. Provide only one.', });
- src/mcp/tools/simulator/build_sim.ts:150-168 (registration)Tool registration exporting the 'build_sim' tool with name, description, schema, and session-aware handler.export default { name: 'build_sim', description: 'Builds an app for an iOS simulator.', schema: publicSchemaObject.shape, // MCP SDK compatibility (public inputs only) handler: createSessionAwareTool<BuildSimulatorParams>({ internalSchema: buildSimulatorSchema as unknown as z.ZodType<BuildSimulatorParams>, logicFunction: build_simLogic, getExecutor: getDefaultCommandExecutor, requirements: [ { allOf: ['scheme'], message: 'scheme is required' }, { oneOf: ['projectPath', 'workspacePath'], message: 'Provide a project or workspace' }, { oneOf: ['simulatorId', 'simulatorName'], message: 'Provide simulatorId or simulatorName' }, ], exclusivePairs: [ ['projectPath', 'workspacePath'], ['simulatorId', 'simulatorName'], ], }), };
- Internal helper function that performs the actual xcodebuild execution for simulator build, handling simulatorId/project paths.async function _handleSimulatorBuildLogic( params: BuildSimulatorParams, executor: CommandExecutor = getDefaultCommandExecutor(), ): Promise<ToolResponse> { const projectType = params.projectPath ? 'project' : 'workspace'; const filePath = params.projectPath ?? params.workspacePath; // Log warning if useLatestOS is provided with simulatorId if (params.simulatorId && params.useLatestOS !== undefined) { log( 'warning', `useLatestOS parameter is ignored when using simulatorId (UUID implies exact device/OS)`, ); } log( 'info', `Starting iOS Simulator build for scheme ${params.scheme} from ${projectType}: ${filePath}`, ); // Ensure configuration has a default value for SharedBuildParams compatibility const sharedBuildParams = { ...params, configuration: params.configuration ?? 'Debug', }; // executeXcodeBuildCommand handles both simulatorId and simulatorName return executeXcodeBuildCommand( sharedBuildParams, { platform: XcodePlatform.iOSSimulator, simulatorName: params.simulatorName, simulatorId: params.simulatorId, useLatestOS: params.simulatorId ? false : params.useLatestOS, // Ignore useLatestOS with ID logPrefix: 'iOS Simulator Build', }, params.preferXcodebuild ?? false, 'build', executor, ); }