Skip to content

Conversation

@jjfeiler
Copy link

@jjfeiler jjfeiler commented Feb 1, 2026

Summary

When using session-set-defaults to configure a watchOS, tvOS, or visionOS scheme, the simulator build tools (build_sim, build_run_sim, test_sim) would incorrectly use "iOS Simulator" as the destination platform, causing build failures.

Problem

After setting session defaults with a Watch scheme:

session-set-defaults --scheme "MyApp Watch App" --simulatorName "Apple Watch Ultra 2"

Running build_sim would fail with:

Unable to find a device matching the provided destination specifier:
    { platform:iOS Simulator, OS:latest, name:Apple Watch Ultra 2 (49mm) }

The available destinations showed watchOS Simulator options, but the tool was hardcoded to use iOS Simulator.

Solution

This PR adds automatic platform detection by querying the scheme's build settings (SDKROOT and SUPPORTED_PLATFORMS) before building. The detected platform is then used to construct the correct destination string.

Changes

  • New file: src/utils/platform-detection.ts - Utility function detectPlatformFromScheme() that:

    • Runs xcodebuild -showBuildSettings for the specified scheme
    • Parses SDKROOT and SUPPORTED_PLATFORMS to determine the target platform
    • Returns the appropriate XcodePlatform enum value (iOS Simulator, watchOS Simulator, etc.)
  • Modified: src/mcp/tools/simulator/build_sim.ts - Calls platform detection before building

  • Modified: src/mcp/tools/simulator/build_run_sim.ts - Calls platform detection before building

  • Modified: src/mcp/tools/simulator/test_sim.ts - Calls platform detection before running tests

  • Updated tests: Account for the additional platform detection call in mocked executors

Test plan

  • All existing tests pass (1157 passed)
  • Tested with iOS scheme - correctly uses iOS Simulator
  • Tested with watchOS scheme - correctly uses watchOS Simulator
  • Manual testing with tvOS and visionOS schemes (not tested, but follows same SDKROOT pattern)

🤖 Generated with Claude Code

When using session-set-defaults to configure a watchOS, tvOS, or visionOS
scheme, the simulator build tools (build_sim, build_run_sim, test_sim)
would incorrectly use "iOS Simulator" as the destination platform,
causing build failures with errors like:

  "Unable to find a device matching the provided destination specifier:
   { platform:iOS Simulator, OS:latest, name:Apple Watch Ultra 2 }"

This change adds automatic platform detection by querying the scheme's
build settings (SDKROOT and SUPPORTED_PLATFORMS) before building.
The detected platform is then used to construct the correct destination
string.

Changes:
- Add src/utils/platform-detection.ts with detectPlatformFromScheme()
- Integrate platform detection into build_sim, build_run_sim, test_sim
- Update tests to account for the additional platform detection call

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 1, 2026

Walkthrough

This pull request introduces automatic platform detection for Xcode simulator builds. A new platform detection utility queries xcodebuild settings to determine the target simulator platform (iOS, watchOS, tvOS, or visionOS) from the scheme's configuration. The build and test flows are updated to invoke this detection as an initial step, followed by the actual build command. Test files are refactored to expect the two-step command sequence, with updated assertions validating platform detection, build invocations, and corresponding log prefix labels for each stage.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change—adding automatic platform detection from scheme build settings—which is the core objective of the pull request.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, solution, and changes made with concrete examples and test results.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Run lint:fix to resolve formatting errors flagged by CI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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