Skip to content

Commit 96021a6

Browse files
authored
fix: handle devicectl launch arguments (#93)
Harness uses devicectl device process launch for physical iOS devices. When app launch arguments are present, devicectl expects them after a -- separator. Without that separator, launch arguments are parsed incorrectly and physical-device startup can fail. Harness also appends --json-output to every devicectl command. That flag must stay before the -- separator so devicectl still treats it as its own option and writes the result JSON file correctly.
1 parent e04177f commit 96021a6

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
__default__: patch
3+
---
4+
5+
Physical iOS app launches now pass Harness launch arguments to `xcrun devicectl` without breaking JSON output collection. This prevents app launch arguments from being misinterpreted as `devicectl` flags and keeps device launches working when custom arguments are provided.

packages/platform-ios/src/__tests__/launch-options.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('Apple app launch options', () => {
3535
'--environment-variables',
3636
'{"FEATURE_X":"1"}',
3737
'com.example.app',
38+
'--',
3839
'--mode=test',
3940
'--retry=1',
4041
]);

packages/platform-ios/src/xcrun/devicectl.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@ export const devicectl = async <TOutput>(
1010
args: string[]
1111
): Promise<TOutput> => {
1212
const tempFile = join(tmpdir(), `devicectl-${randomUUID()}.json`);
13+
const separatorIndex = args.indexOf('--');
14+
const argsWithJsonOutput =
15+
separatorIndex === -1
16+
? [...args, '--json-output', tempFile]
17+
: [
18+
...args.slice(0, separatorIndex),
19+
'--json-output',
20+
tempFile,
21+
...args.slice(separatorIndex),
22+
];
1323

1424
await spawn('xcrun', [
1525
'devicectl',
1626
command,
17-
...args,
18-
'--json-output',
19-
tempFile,
27+
...argsWithJsonOutput,
2028
]);
2129

30+
if (!fs.existsSync(tempFile)) {
31+
throw new Error(`devicectl did not produce JSON output at ${tempFile}`);
32+
}
33+
2234
const output = fs.readFileSync(tempFile, 'utf8');
2335
fs.unlinkSync(tempFile);
2436

@@ -106,7 +118,11 @@ export const getDeviceCtlLaunchArgs = (
106118
args.push('--environment-variables', JSON.stringify(environment));
107119
}
108120

109-
args.push(bundleId, ...(options?.arguments ?? []));
121+
args.push(bundleId);
122+
123+
if (options?.arguments?.length) {
124+
args.push('--', ...options.arguments);
125+
}
110126

111127
return args;
112128
};

0 commit comments

Comments
 (0)