ui_swipe
Simulates swipe gestures on the iOS Simulator screen by defining start and end coordinates, enabling precise UI interaction testing and control.
Instructions
Swipe on the screen in the iOS Simulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| delta | No | The size of each step in the swipe (default is 1) | |
| udid | No | Udid of target, can also be set with the IDB_UDID env var | |
| x_end | Yes | The ending x-coordinate | |
| x_start | Yes | The starting x-coordinate | |
| y_end | Yes | The ending y-coordinate | |
| y_start | Yes | The starting y-coordinate |
Implementation Reference
- src/index.ts:412-453 (handler)The handler function that executes the ui_swipe tool logic by calling the idb CLI with swipe parameters.async ({ duration, udid, x_start, y_start, x_end, y_end, delta }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "swipe", "--udid", actualUdid, ...(duration ? ["--duration", duration] : []), ...(delta ? ["--delta", String(delta)] : []), "--json", // When passing user-provided values to a command, it's crucial to use `--` // to separate the command's options from positional arguments. // This prevents the shell from misinterpreting the arguments as options. "--", String(x_start), String(y_start), String(x_end), String(y_end) ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Swiped successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error swiping on the screen: ${toError(error).message}` ), }, ], }; } }
- src/index.ts:392-411 (schema)Zod schema defining the input parameters for the ui_swipe tool, including coordinates, optional duration, udid, and delta.duration: z .string() .regex(/^\d+(\.\d+)?$/) .optional() .describe("Swipe duration in seconds (e.g., 0.1)"), udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), x_start: z.number().describe("The starting x-coordinate"), y_start: z.number().describe("The starting y-coordinate"), x_end: z.number().describe("The ending x-coordinate"), y_end: z.number().describe("The ending y-coordinate"), delta: z .number() .optional() .describe("The size of each step in the swipe (default is 1)") .default(1), },
- src/index.ts:387-455 (registration)Registration of the ui_swipe tool using server.tool, conditionally filtered by isToolFiltered.if (!isToolFiltered("ui_swipe")) { server.tool( "ui_swipe", "Swipe on the screen in the iOS Simulator", { duration: z .string() .regex(/^\d+(\.\d+)?$/) .optional() .describe("Swipe duration in seconds (e.g., 0.1)"), udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), x_start: z.number().describe("The starting x-coordinate"), y_start: z.number().describe("The starting y-coordinate"), x_end: z.number().describe("The ending x-coordinate"), y_end: z.number().describe("The ending y-coordinate"), delta: z .number() .optional() .describe("The size of each step in the swipe (default is 1)") .default(1), }, async ({ duration, udid, x_start, y_start, x_end, y_end, delta }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "swipe", "--udid", actualUdid, ...(duration ? ["--duration", duration] : []), ...(delta ? ["--delta", String(delta)] : []), "--json", // When passing user-provided values to a command, it's crucial to use `--` // to separate the command's options from positional arguments. // This prevents the shell from misinterpreting the arguments as options. "--", String(x_start), String(y_start), String(x_end), String(y_end) ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Swiped successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error swiping on the screen: ${toError(error).message}` ), }, ], }; } } ); }