Reuse an already-booted iOS simulator instead of hanging - #45
Conversation
IOSEmulatorManager.getTargetEmulator always picked the most recent iPhone simulator from `simctl list`, regardless of whether a different simulator was already booted. When one was, the boot-ready check kept failing and the manager tried to boot a second simulator, which conflicted with the first and hung until the retry loop timed out. Now, unless IOS_EMU pins a specific simulator, the picker reuses whichever simulator is already booted. Rewritten with async/await, matching the style already used elsewhere in this file.
| else { | ||
| // Use the simulator specified on the command line. | ||
| deferred.resolve(targetIOSEmulator); | ||
| IOSEmulatorManager.prototype.getTargetEmulator = async function () { |
There was a problem hiding this comment.
Note how we are converting this old code to modern async/await syntax. That's why the diff is more than a few lines.
There was a problem hiding this comment.
Pull request overview
Updates iOS simulator selection to reuse an already-booted simulator and avoid test setup hangs.
Changes:
- Prefer an active simulator before falling back to the default iPhone.
- Remove obsolete simulator-shutdown guidance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
code-push-plugin-testing-framework/script/platform.js |
Revises iOS simulator selection. |
CLAUDE.md |
Removes outdated shutdown instructions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let targetEmulator = process.env.IOS_EMU; | ||
| if (!targetEmulator) { | ||
| try { | ||
| const bootedUdid = await testUtil_1.TestUtil.getProcessOutput("xcrun simctl getenv booted SIMULATOR_UDID", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }); |
There was a problem hiding this comment.
If multiple simulators are already running, this command rejects, the catch selects a different listed iPhone without shutting the existing devices down
I would say this is an expected (although implicit) behavior, not a big deal.
A lone booted tvOS/watchOS device can likewise be selected as the test target.
Technically correct, but not a big deal IMHO in this project's context.
#44 is going to run a second batch of tests (plain XCTests) on the same booted simulator. Perfect time to solve this known issue.