Skip to content

Commit b990271

Browse files
authored
fix(ios): use current devicectl capture-screenshot syntax for physical devices (callstack#1769)
The direct-capture fallback ran `devicectl device screenshot --device <id> <path>`, which current Xcode devicectl rejects with "Unknown option '--device'", forcing every physical-device screenshot into the slower XCTest runner path. Xcode's devicectl now requires `devicectl device capture screenshot --device <id> --destination <path>`. Fixes callstack#1760
1 parent eabc936 commit b990271

2 files changed

Lines changed: 48 additions & 5 deletions

File tree

‎src/platforms/apple/core/__tests__/physical-device-screenshot.test.ts‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
11
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
3-
import { shouldFallbackToRunnerForIosScreenshot } from '../physical-device-screenshot.ts';
3+
import { IOS_DEVICE } from '../../../../__tests__/test-utils/index.ts';
4+
import {
5+
captureCoreDeviceScreenshot,
6+
shouldFallbackToRunnerForIosScreenshot,
7+
} from '../physical-device-screenshot.ts';
8+
import { createLocalAppleToolProvider, withAppleToolProvider } from '../tool-provider.ts';
49
import { AppError } from '@agent-device/kernel/errors';
510

11+
test('captureCoreDeviceScreenshot invokes devicectl with the current capture-screenshot syntax', async () => {
12+
const calls: Array<{ cmd: string; args: string[] }> = [];
13+
14+
await withAppleToolProvider(
15+
createLocalAppleToolProvider({
16+
runCommand: async (cmd, args) => {
17+
calls.push({ cmd, args });
18+
return { exitCode: 0, stdout: '', stderr: '' };
19+
},
20+
}),
21+
async () =>
22+
await captureCoreDeviceScreenshot(IOS_DEVICE, '/tmp/out.png', {
23+
runRunnerCommand: async () => {
24+
throw new Error('devicectl capture should have succeeded without a runner fallback');
25+
},
26+
}),
27+
);
28+
29+
assert.deepEqual(calls, [
30+
{
31+
cmd: 'xcrun',
32+
args: [
33+
'devicectl',
34+
'device',
35+
'capture',
36+
'screenshot',
37+
'--device',
38+
IOS_DEVICE.id,
39+
'--destination',
40+
'/tmp/out.png',
41+
],
42+
},
43+
]);
44+
});
45+
646
test('shouldFallbackToRunnerForIosScreenshot detects removed devicectl subcommand output', () => {
747
const error = new AppError('COMMAND_FAILED', 'Failed to capture iOS screenshot', {
848
stderr: "error: Unknown option '--device'",

‎src/platforms/apple/core/physical-device-screenshot.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ export async function captureCoreDeviceScreenshot(
2525
): Promise<void> {
2626
if (!options.preferRunner) {
2727
try {
28-
await runIosDevicectl(['device', 'screenshot', '--device', device.id, outPath], {
29-
action: 'capture iOS screenshot',
30-
deviceId: device.id,
31-
});
28+
await runIosDevicectl(
29+
['device', 'capture', 'screenshot', '--device', device.id, '--destination', outPath],
30+
{
31+
action: 'capture iOS screenshot',
32+
deviceId: device.id,
33+
},
34+
);
3235
return;
3336
} catch (error) {
3437
if (!shouldFallbackToRunnerForIosScreenshot(error)) throw error;

0 commit comments

Comments
 (0)