Skip to content

Commit b0977c8

Browse files
authored
fix: wrap booting simulator in try catch and add special case for when it says it's booted already (#235)
* fix: wrap booting simulator in try catch and add special case for when it says it's booted already * changeset
1 parent 8eb7705 commit b0977c8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rnef/platform-apple-helpers': patch
3+
---
4+
5+
fix: wrap booting simulator in try catch and add special case for when it says it's booted already

packages/platform-apple-helpers/src/lib/commands/run/runOnSimulator.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,23 @@ export async function runOnSimulator(
4646
}
4747

4848
async function bootSimulator(selectedSimulator: Device) {
49-
await spawn('xcrun', ['simctl', 'boot', selectedSimulator.udid]);
49+
try {
50+
await spawn('xcrun', ['simctl', 'boot', selectedSimulator.udid]);
51+
} catch (error) {
52+
if (
53+
// It may happen on GitHub Actions when the simulator is already booted,
54+
// even though the simctl returns its state as Shutdown
55+
(error as SubprocessError).stderr.includes(
56+
'Unable to boot device in current state: Booted'
57+
)
58+
) {
59+
logger.debug(`Simulator ${selectedSimulator.udid} already booted. Skipping.`);
60+
return;
61+
}
62+
throw new RnefError('Failed to boot Simulator', {
63+
cause: (error as SubprocessError).stderr,
64+
});
65+
}
5066
}
5167

5268
export default async function installAppOnSimulator(

0 commit comments

Comments
 (0)