diff --git a/src/mcp/tools/device/__tests__/build_device.test.ts b/src/mcp/tools/device/__tests__/build_device.test.ts index 7ac5812b..4e4d0175 100644 --- a/src/mcp/tools/device/__tests__/build_device.test.ts +++ b/src/mcp/tools/device/__tests__/build_device.test.ts @@ -346,5 +346,32 @@ describe('build_device plugin', () => { ]); expect(spy.commandCalls[0].logPrefix).toBe('iOS Device Build'); }); + + it('should target watchOS platform when platform=watchOS is provided', async () => { + const spy = createSpyExecutor(); + + const { result } = await runToolLogic(() => + buildDeviceLogic( + { + projectPath: '/path/to/MyWatchApp.xcodeproj', + scheme: 'MyWatchApp', + platform: 'watchOS', + }, + spy.executor, + ), + ); + + expect(spy.commandCalls).toHaveLength(1); + const args = spy.commandCalls[0].args; + const destinationIndex = args.indexOf('-destination'); + expect(destinationIndex).toBeGreaterThan(-1); + expect(args[destinationIndex + 1]).toBe('generic/platform=watchOS'); + expect(spy.commandCalls[0].logPrefix).toBe('watchOS Device Build'); + expect(result.nextStepParams).toEqual( + expect.objectContaining({ + get_device_app_path: expect.objectContaining({ platform: 'watchOS' }), + }), + ); + }); }); }); diff --git a/src/mcp/tools/device/build_device.ts b/src/mcp/tools/device/build_device.ts index 2a5e4095..f5787f61 100644 --- a/src/mcp/tools/device/build_device.ts +++ b/src/mcp/tools/device/build_device.ts @@ -46,11 +46,11 @@ const baseSchemaObject = z.object({ projectPath: z.string().optional().describe('Path to the .xcodeproj file'), workspacePath: z.string().optional().describe('Path to the .xcworkspace file'), scheme: z.string().describe('The scheme to build'), + platform: devicePlatformSchema, configuration: z.string().optional().describe('Build configuration (Debug, Release)'), derivedDataPath: z.string().optional(), extraArgs: z.array(z.string()).optional(), preferXcodebuild: z.boolean().optional(), - platform: devicePlatformSchema, }); const buildDeviceSchema = z.preprocess( @@ -128,6 +128,9 @@ export async function buildDeviceLogic( ...(params.derivedDataPath !== undefined ? { derivedDataPath: params.derivedDataPath } : {}), + ...(params.platform !== undefined + ? { platform: String(mapDevicePlatform(params.platform)) } + : {}), }, }; }