Skip to content

Commit 405efdb

Browse files
fabriziocuccizoontek
authored andcommitted
Avoid spawning a new iOS simulator if one is already booted (facebook#55931)
Summary: Pull Request resolved: facebook#55931 Changelog: [Internal] Previously, `testRNTesterIOS` would either unconditionally boot a new simulator (local build path) or check only for an exact "iPhone 16 Pro" match (CI artifacts path). This caused a new iOS simulator to always spawn even when one was already open. Extracted a `bootSimulatorIfNeeded` helper that checks for any booted simulator via `xcrun simctl list devices booted` before attempting to boot a new one. Reviewed By: cipolleschi Differential Revision: D95368633 fbshipit-source-id: 858bd235486597b5c9dbb0b904fcd95707b92b13
1 parent b08d237 commit 405efdb

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,7 @@ async function testRNTesterIOS(
102102
exec(`unzip ${hermesAppZipPath} -d ${appOutputFolder}`);
103103

104104
// boot device
105-
const bootedDevice = String(
106-
exec('xcrun simctl list | grep "iPhone 16 Pro" | grep Booted', {
107-
silent: true,
108-
}),
109-
).trim();
110-
if (!bootedDevice || bootedDevice.length === 0) {
111-
exec('xcrun simctl boot "iPhone 16 Pro"');
112-
}
105+
bootSimulatorIfNeeded();
113106

114107
// install app on device
115108
exec(`xcrun simctl install booted ${appOutputFolder}`);
@@ -118,12 +111,13 @@ async function testRNTesterIOS(
118111
`USE_HERMES=1 CI=${onReleaseBranch.toString()} RCT_NEW_ARCH_ENABLED=1 bundle exec pod install --ansi`,
119112
);
120113

114+
// boot device
115+
bootSimulatorIfNeeded();
116+
121117
// build the app on iOS simulator
122118
exec(
123119
'xcodebuild -workspace RNTesterPods.xcworkspace -scheme RNTester -sdk "iphonesimulator" -destination "generic/platform=iOS Simulator" -derivedDataPath "/tmp/RNTesterBuild"',
124120
);
125-
// boot device
126-
exec('xcrun simctl boot "iPhone 16 Pro"');
127121
// install app on device
128122
exec(
129123
'xcrun simctl install booted "/tmp/RNTesterBuild/Build/Products/Debug-iphonesimulator/RNTester.app"',
@@ -324,6 +318,18 @@ async function testRNTestProject(
324318
popd();
325319
}
326320

321+
function bootSimulatorIfNeeded() {
322+
const bootedDevices = String(
323+
exec('xcrun simctl list devices booted', {silent: true}),
324+
).trim();
325+
// Check if there is at least one booted device by looking for a line with a UDID
326+
if (/\([A-F0-9-]+\)/i.test(bootedDevices)) {
327+
console.info('An iOS simulator is already booted, skipping boot.');
328+
return;
329+
}
330+
exec('xcrun simctl boot "iPhone 16 Pro"');
331+
}
332+
327333
async function main() {
328334
/*
329335
* see the test-local-e2e.js script for clean up process

0 commit comments

Comments
 (0)