fix(simulator): Make simulator platform inference deterministic#472
Merged
Conversation
An iOS app that also supports visionOS could build for the wrong platform: when the selected simulator was unavailable (e.g. its runtime was removed by an Xcode upgrade), inference fell back to guessing from SUPPORTED_PLATFORMS, which prefers xrsimulator over iphonesimulator. - Persist simulatorPlatform during setup, derived from the selected simulator's runtime, so tools short-circuit on a cached authoritative value instead of guessing - Remove the build-settings and default-iOS fallbacks from inferPlatform; throw a clear error when no source resolves - Hydrate the CLI session store from project config so the cached platform is visible to one-shot CLI invocations - Filter unavailable simulators out of the setup picker - Invalidate the cached platform when Xcode sync changes the selector - Keep name -> id re-materialization in the background refresh (simulatorName stays the canonical, machine-portable selector for SCM-shared configs) and skip it when nothing resolves - Remove the now-dead detectPlatformFromScheme Co-Authored-By: Claude <noreply@anthropic.com>
commit: |
Codify two rules in AGENTS.md and CLAUDE.md: - Never run the snapshot or smoke test suites without explicit user permission; they are expensive (~7 min, real xcodebuild/simctl processes) while the unit suite, typecheck, lint, and build remain free to run - Structured errors (domain results with didError) are for domain errors only; system errors with the MCP server or CLI itself must surface as runtime tool errors Co-Authored-By: Claude <noreply@anthropic.com>
- Clear the cached simulatorPlatform when the background refresh remaps the simulator id but the platform recompute fails, so a new id is never paired with the previous device's platform - Report simulatorPlatform changes in the setup summary Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4df2605. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Simulator tools could build for the wrong platform. With an iPhone simulator selected via
setup,simulator buildproducedplatform=visionOS Simulatorfor an iOS app that also supports visionOS, failing with "Unable to find a device matching the provided destination specifier".Root cause
When the selected simulator is unavailable (e.g. its runtime was removed by an Xcode upgrade, leaving a stale device record), platform inference found nothing in
simctl list devices availableand fell through to guessing from the scheme'sSUPPORTED_PLATFORMS— which checkedxrsimulatorbeforeiphonesimulator. For any multi-platform app the result was a coin toss, rigged toward visionOS.Changes
simulatorPlatform, derived from the selected simulator's runtime. Inference short-circuits on this cached, device-derived value — the session-defaults field existed but nothing ever wrote it.inferPlatform. Guessing a destination fromSUPPORTED_PLATFORMSis inherently non-deterministic for multi-platform apps; if no authoritative source resolves, tools now fail fast with a clear error pointing atsetup.build_run_simshows the real platform name instead of downgrading to a generic "Simulator" when inference came from the cache.detectPlatformFromSchemeremoved — it carried the visionOS-over-iOS ordering bug and had no remaining callers.The background defaults refresh keeps its name → id re-materialization:
simulatorNameremains the canonical, machine-portable selector for SCM-shared configs, and the refresh updates the machine-local UDID from it. This contract, and the deliberate asymmetry that one-shot CLI runs stay deterministic for CI (fail fast on a stale/foreign UDID rather than silently re-resolving), is now codified in code comments and schema descriptions.Notes for review
inferPlatformnow throws when it cannot resolve —build_run_simconverts that into a structured error via its existing prepare catch, whilebuild_sim/test_simsurface it as a runtime tool error.Co-Authored-By: Claude noreply@anthropic.com