Skip to content

ci: wait for the test simulator before running xcodebuild - #557

Merged
edusperoni merged 2 commits into
mainfrom
ci/wait-for-simulator
Nov 11, 2026
Merged

edusperoni merged 2 commits into
mainfrom
ci/wait-for-simulator

Conversation

@edusperoni

@edusperoni edusperoni commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

The Test and Test (ASan) jobs sometimes burn their first "Xcode Tests" attempt in about a minute, without building anything:

xcodebuild: error: Unable to find a device matching the provided destination specifier:
		{ platform:iOS Simulator, OS:latest, name:iPhone 16 Pro }
...
Warning: Attempt 1 failed. Reason: Child_process exited with error code 70

On a fresh runner, CoreSimulator can still be enumerating its devices when the step starts, so the destination doesn't resolve yet. The retry, about 50 s later, finds the device and passes. This happened on both test jobs of #547 and on the ASan job of feat/ios-stdio-forwarding, so it isn't tied to any one change.

Change

  • scripts/wait-for-simulator.sh --name <device> [--timeout <s>] polls xcrun simctl list devices available until an iOS device with that name is listed. A failing simctl call while CoreSimulator starts counts as "not yet". After the timeout (300 s by default) it fails with an ::error:: annotation and the device list.
  • The test job runs it as "Wait for the test simulator" right before "Xcode Tests", with the same device name as the -destination.

It doesn't pre-boot the simulator. That would compete with the build on the runner's few cores, and the race is only about the device being listed.

Testing

  • Ran the script locally:
    • with an existing device name it returns at once;
    • with a missing name it times out with exit 1, the annotation and the device list;
    • it rejects a missing --name, a non-numeric --timeout and unknown flags.
  • Both --flag value and --flag=value forms work.
  • On this PR's first CI run the step found the simulator after 28 s (Test) and 125 s (Test (ASan)), and "Xcode Tests" passed on its first attempt in both jobs. The 125 s is why the default is 300 s rather than 180 s.

On a fresh runner CoreSimulator can still be enumerating its devices when
the test step starts. xcodebuild then fails to resolve
`-destination ...,name=iPhone 16 Pro` ("Unable to find a device matching
the provided destination specifier", exit code 70) and the retry action
spends its second attempt on what was only a startup race.

A new step runs scripts/wait-for-simulator.sh, which polls
`xcrun simctl list devices available` until a device with that name is
listed (180 s by default) and otherwise fails with the device list in the
log.
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

On the first CI run with the wait step, the ASan runner listed the
simulator only after 125 s, too close to the 180 s default.
@edusperoni
edusperoni merged commit 5485f33 into main Nov 11, 2026
8 of 10 checks passed
@edusperoni
edusperoni deleted the ci/wait-for-simulator branch November 11, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant