fastlane scan hangs after tests finish

All tests pass, but fastlane scan never exits — it hangs after the last test during teardown, result-bundle writing, or simulator shutdown.

Partial fit Likely class: post-test teardown / result-bundle / simulator shutdown stall · Updated

Symptom

The tests themselves finish — you can see all of them pass in the log — but fastlane scan (which drives xcodebuild) never returns control. The process sits there after the last test, and eventually a CI-like job times out or you cancel it manually.

What it usually looks like

Why it happens / likely failure classes

The tests passing tells you the test execution path is fine. The stall is in what happens after:

Quick checks

# Watch what the run is actually doing while it "hangs"
sample $(pgrep -n xcodebuild) 5 -mayDie 2>/dev/null

# Are simulators stuck mid-shutdown?
xcrun simctl list devices | grep -i 'booting\|shutting'

# Lingering test/helper processes after "completion"?
pgrep -lf 'xcodebuild|simctl|Simulator|YourAppName'

Try the same scheme with xcodebuild directly (no scan) to learn whether the stall is in xcodebuild/CoreSimulator or in scan’s post-processing:

xcodebuild test -scheme YourScheme \
  -destination "platform=iOS Simulator,id=<UDID>" \
  -resultBundlePath /tmp/run.xcresult

Manual mitigations

When XCSteward may help

This is a partial fit — XCSteward focuses on the execution and simulator-lifecycle parts of the problem, which is where many of these stalls actually live:

It is worth testing against this class of failure when the hang is in simulator shutdown or process cleanup.

When XCSteward probably will not help

Common questions

What does "fastlane scan hangs after tests finish" usually mean?
It usually points to post-test teardown / result-bundle / simulator shutdown stall. All tests pass, but fastlane scan never exits — it hangs after the last test during teardown, result-bundle writing, or simulator shutdown. Start by checking simulator readiness, destination selection, CoreSimulator/simctl responsiveness, and whether another xcodebuild, simctl, or Simulator process is already active before treating it as a test-code failure.
Can XCSteward help with "fastlane scan hangs after tests finish"?
This is a partial fit. XCSteward may help when the failure comes from execution readiness, destination selection, timeouts, cleanup, or contention. It probably will not help when the root cause is missing configuration, a broken runtime, a test-code bug, or a vendor image defect.
What should I check first?
Check whether xcrun simctl commands return promptly, whether xcodebuild can resolve a concrete simulator destination, whether the device is truly ready rather than merely Booted, and whether concurrent agents, scripts, or manual runs are touching the same simulator subsystem.