Skip to content

Commit 9618433

Browse files
fabriziocuccizoontek
authored andcommitted
Boot latest available iOS simulator instead of hardcoded iPhone 16 Pro (facebook#55932)
Summary: Pull Request resolved: facebook#55932 Changelog: [Internal] When no simulator is already booted, dynamically discover the latest available iOS runtime and boot the first iPhone device under it, instead of hardcoding "iPhone 16 Pro". This uses `xcrun simctl list devices iPhone available -j` to query available devices and picks the last iOS runtime alphabetically (i.e. the newest). Also moved the `bootSimulatorIfNeeded` call before the `xcodebuild` invocation on the local build path, since `xcodebuild -destination "generic/platform=iOS Simulator"` can itself trigger a new simulator boot. Reviewed By: cipolleschi Differential Revision: D95371266 fbshipit-source-id: 0f4e2a476c971e774b6461edbecba4623f6befa6
1 parent 405efdb commit 9618433

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

scripts/release-testing/test-release-local.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,30 @@ function bootSimulatorIfNeeded() {
327327
console.info('An iOS simulator is already booted, skipping boot.');
328328
return;
329329
}
330-
exec('xcrun simctl boot "iPhone 16 Pro"');
330+
331+
// Find the latest available iPhone simulator by picking the last iOS runtime
332+
// and the first iPhone device listed under it.
333+
const devicesJson = JSON.parse(
334+
String(
335+
exec('xcrun simctl list devices iPhone available -j', {silent: true}),
336+
),
337+
);
338+
const runtimes = Object.keys(devicesJson.devices)
339+
.filter(r => r.startsWith('com.apple.CoreSimulator.SimRuntime.iOS'))
340+
.sort();
341+
const latestRuntime = runtimes[runtimes.length - 1];
342+
const device =
343+
latestRuntime != null
344+
? devicesJson.devices[latestRuntime].find(d => d.name.includes('iPhone'))
345+
: null;
346+
347+
if (device != null) {
348+
console.info(`Booting ${device.name} (${latestRuntime})...`);
349+
exec(`xcrun simctl boot "${device.udid}"`);
350+
} else {
351+
console.error('No available iPhone simulator found.');
352+
process.exit(1);
353+
}
331354
}
332355

333356
async function main() {

0 commit comments

Comments
 (0)