DerivedData contamination between iOS test runs

Test runs interfere through shared DerivedData, result bundles, or logs — you get stale builds, overwritten .xcresult, or results from the wrong run.

Strong fit Likely class: shared artifacts / DerivedData contamination · Updated

Symptom

Runs interfere through shared on-disk state. You see stale builds, an .xcresult that belongs to a different run, missing or clobbered logs, or results that do not match the code you just changed.

What it usually looks like

Why it happens / likely failure classes

The default paths are shared and global, which is fine for one run at a time and fragile otherwise:

Quick checks

# Are multiple runs sharing the default DerivedData right now?
ls -la ~/Library/Developer/Xcode/DerivedData
pgrep -lf xcodebuild

# Confirm each run can take its own DerivedData + result bundle
xcodebuild test -scheme YourScheme \
  -destination "platform=iOS Simulator,id=<UDID>" \
  -derivedDataPath "/tmp/dd-$RUN_ID" \
  -resultBundlePath "/tmp/result-$RUN_ID.xcresult"

Manual mitigations

When XCSteward may help

Per-run isolation of artifacts is one of XCSteward’s core design goals:

A strong candidate to test against this class of failure, particularly when several runs share one Mac.

When XCSteward probably will not help

Common questions

What does "DerivedData contamination between iOS test runs" usually mean?
It usually points to shared artifacts / DerivedData contamination. Test runs interfere through shared DerivedData, result bundles, or logs — you get stale builds, overwritten .xcresult, or results from the wrong run. 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 "DerivedData contamination between iOS test runs"?
This is a strong fit when the failure is operational: simulator readiness, destination resolution, CoreSimulator responsiveness, cleanup, timeouts, or local concurrency. XCSteward may help by making those phases bounded, serialized, and easier to inspect. It will not fix broken tests, code signing, missing runtimes, or vendor image bugs.
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.