Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .nx/version-plans/fix-devicectl-launch-args.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
__default__: patch
---

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.
1 change: 1 addition & 0 deletions packages/platform-ios/src/__tests__/launch-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('Apple app launch options', () => {
'--environment-variables',
'{"FEATURE_X":"1"}',
'com.example.app',
'--',
'--mode=test',
'--retry=1',
]);
Expand Down
24 changes: 20 additions & 4 deletions packages/platform-ios/src/xcrun/devicectl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ export const devicectl = async <TOutput>(
args: string[]
): Promise<TOutput> => {
const tempFile = join(tmpdir(), `devicectl-${randomUUID()}.json`);
const separatorIndex = args.indexOf('--');
const argsWithJsonOutput =
separatorIndex === -1
? [...args, '--json-output', tempFile]
: [
...args.slice(0, separatorIndex),
'--json-output',
tempFile,
...args.slice(separatorIndex),
];

await spawn('xcrun', [
'devicectl',
command,
...args,
'--json-output',
tempFile,
...argsWithJsonOutput,
]);

if (!fs.existsSync(tempFile)) {
throw new Error(`devicectl did not produce JSON output at ${tempFile}`);
}

const output = fs.readFileSync(tempFile, 'utf8');
fs.unlinkSync(tempFile);

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

args.push(bundleId, ...(options?.arguments ?? []));
args.push(bundleId);

if (options?.arguments?.length) {
args.push('--', ...options.arguments);
}

return args;
};
Expand Down
Loading