Skip to content

Commit f69b379

Browse files
committed
fix: use supported simctl diagnose arguments for iOS crash capture
1 parent ec1543c commit f69b379

File tree

5 files changed

+75
-67
lines changed

5 files changed

+75
-67
lines changed

apps/playground/rn-harness.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default {
8282
}),
8383
applePlatform({
8484
name: 'ios-crash-pre-rn',
85-
device: appleSimulator('iPhone 16 Pro', '18.6'),
85+
device: appleSimulator('iPhone 17 Pro', '26.2'),
8686
bundleId: 'com.harnessplayground',
8787
appLaunchOptions: {
8888
environment: {
@@ -92,7 +92,7 @@ export default {
9292
}),
9393
applePlatform({
9494
name: 'ios-crash-delayed',
95-
device: appleSimulator('iPhone 16 Pro', '18.6'),
95+
device: appleSimulator('iPhone 17 Pro', '26.2'),
9696
bundleId: 'com.harnessplayground',
9797
appLaunchOptions: {
9898
environment: {

packages/platform-ios/src/__tests__/crash-diagnostics.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('collectCrashArtifacts', () => {
1414

1515
it('collects simulator crash artifacts from simctl diagnose output', async () => {
1616
const outputRoot = fs.mkdtempSync(
17-
join(tmpdir(), 'rn-harness-simctl-diagnose-')
17+
join(tmpdir(), 'rn-harness-simctl-diagnose-'),
1818
);
1919
const crashPath = join(outputRoot, 'HarnessPlayground.ips');
2020
fs.writeFileSync(
@@ -36,14 +36,14 @@ describe('collectCrashArtifacts', () => {
3636
},
3737
}),
3838
].join('\n'),
39-
'utf8'
39+
'utf8',
4040
);
4141

4242
vi.spyOn(simctl, 'diagnose').mockImplementation(
4343
async (_udid, outputDir) => {
4444
fs.mkdirSync(outputDir, { recursive: true });
4545
fs.copyFileSync(crashPath, join(outputDir, 'HarnessPlayground.ips'));
46-
}
46+
},
4747
);
4848

4949
const artifacts = await collectCrashArtifacts({
@@ -67,7 +67,7 @@ describe('collectCrashArtifacts', () => {
6767

6868
it('collects device crash artifacts from systemCrashLogs before falling back to diagnose', async () => {
6969
const outputRoot = fs.mkdtempSync(
70-
join(tmpdir(), 'rn-harness-devicectl-crash-logs-')
70+
join(tmpdir(), 'rn-harness-devicectl-crash-logs-'),
7171
);
7272
const crashPath = join(outputRoot, 'HarnessPlayground.crash');
7373
fs.writeFileSync(
@@ -78,7 +78,7 @@ describe('collectCrashArtifacts', () => {
7878
'Date/Time: 2026-03-12 11:35:08 +0000',
7979
'Exception Type: EXC_CRASH (SIGABRT)',
8080
].join('\n'),
81-
'utf8'
81+
'utf8',
8282
);
8383

8484
vi.spyOn(devicectl, 'listFiles').mockResolvedValue([
@@ -87,7 +87,7 @@ describe('collectCrashArtifacts', () => {
8787
vi.spyOn(devicectl, 'copyFileFrom').mockImplementation(
8888
async (_deviceId, options) => {
8989
fs.copyFileSync(crashPath, options.destination);
90-
}
90+
},
9191
);
9292
const diagnoseSpy = vi
9393
.spyOn(devicectl, 'diagnose')
@@ -113,7 +113,7 @@ describe('collectCrashArtifacts', () => {
113113

114114
it('persists matched crash artifacts with the provided writer', async () => {
115115
const sourceRoot = fs.mkdtempSync(
116-
join(tmpdir(), 'rn-harness-crash-diagnostics-')
116+
join(tmpdir(), 'rn-harness-crash-diagnostics-'),
117117
);
118118
const sourcePath = join(sourceRoot, 'HarnessPlayground.ips');
119119
fs.writeFileSync(
@@ -135,14 +135,14 @@ describe('collectCrashArtifacts', () => {
135135
},
136136
}),
137137
].join('\n'),
138-
'utf8'
138+
'utf8',
139139
);
140140

141141
vi.spyOn(simctl, 'diagnose').mockImplementation(
142142
async (_udid, outputDir) => {
143143
fs.mkdirSync(outputDir, { recursive: true });
144144
fs.copyFileSync(sourcePath, join(outputDir, 'HarnessPlayground.ips'));
145-
}
145+
},
146146
);
147147

148148
const writer = createCrashArtifactWriter({

packages/platform-ios/src/__tests__/simctl.test.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('simctl startup', () => {
1818
expect(spawnSpy).toHaveBeenCalledWith(
1919
'xcrun',
2020
['simctl', 'bootstatus', 'sim-udid', '-b'],
21-
{ signal }
21+
{ signal },
2222
);
2323
});
2424

@@ -29,15 +29,19 @@ describe('simctl startup', () => {
2929

3030
await diagnose('sim-udid', '/tmp/sim-diagnose-output');
3131

32-
expect(spawnSpy).toHaveBeenCalledWith('xcrun', [
33-
'simctl',
34-
'diagnose',
35-
'--udid',
36-
'sim-udid',
37-
'--no-archive',
38-
'--output',
39-
'/tmp/sim-diagnose-output',
40-
'-b',
41-
]);
32+
expect(spawnSpy).toHaveBeenCalledWith(
33+
'xcrun',
34+
[
35+
'simctl',
36+
'diagnose',
37+
'--udid=sim-udid',
38+
'--no-archive',
39+
'--output=/tmp/sim-diagnose-output',
40+
'-b',
41+
],
42+
{
43+
stdin: { string: '\n' },
44+
},
45+
);
4246
});
4347
});

packages/platform-ios/src/crash-diagnostics.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ const parseCrashArtifacts = ({
208208
return artifact;
209209
})
210210
.filter((artifact): artifact is DiagnosedCrashArtifact =>
211-
Boolean(artifact)
211+
Boolean(artifact),
212212
);
213213

214214
return candidates.sort((left, right) => {
@@ -252,7 +252,7 @@ const collectPhysicalCrashArtifacts = async ({
252252
recursive: true,
253253
});
254254
const filteredCrashLogPaths = remoteCrashLogPaths.filter((remotePath) =>
255-
processNames.some((processName) => remotePath.includes(processName))
255+
processNames.some((processName) => remotePath.includes(processName)),
256256
);
257257

258258
if (filteredCrashLogPaths.length > 0) {
@@ -311,7 +311,7 @@ const collectPhysicalCrashArtifacts = async ({
311311
};
312312

313313
export const collectCrashArtifacts = async (
314-
options: CollectCrashArtifactsOptions
314+
options: CollectCrashArtifactsOptions,
315315
): Promise<DiagnosedCrashArtifact[]> => {
316316
crashDiagnosticsLogger.debug('collecting crash artifacts: %o', {
317317
targetId: options.targetId,
@@ -360,7 +360,7 @@ export const waitForCrashArtifact = async ({
360360
}
361361

362362
await new Promise((resolve) =>
363-
setTimeout(resolve, CRASH_ARTIFACT_POLL_INTERVAL_MS)
363+
setTimeout(resolve, CRASH_ARTIFACT_POLL_INTERVAL_MS),
364364
);
365365
} while (true);
366366
};

0 commit comments

Comments
 (0)