Add automatic platform detection from scheme build settings#196
Add automatic platform detection from scheme build settings#196jjfeiler wants to merge 3 commits intocameroncooke:mainfrom
Conversation
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>
WalkthroughThis 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)
✏️ 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. Comment |
Run lint:fix to resolve formatting errors flagged by CI. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
When using
session-set-defaultsto 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:
Running
build_simwould fail with: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 (
SDKROOTandSUPPORTED_PLATFORMS) before building. The detected platform is then used to construct the correct destination string.Changes
New file:
src/utils/platform-detection.ts- Utility functiondetectPlatformFromScheme()that:xcodebuild -showBuildSettingsfor the specified schemeSDKROOTandSUPPORTED_PLATFORMSto determine the target platformXcodePlatformenum value (iOS Simulator, watchOS Simulator, etc.)Modified:
src/mcp/tools/simulator/build_sim.ts- Calls platform detection before buildingModified:
src/mcp/tools/simulator/build_run_sim.ts- Calls platform detection before buildingModified:
src/mcp/tools/simulator/test_sim.ts- Calls platform detection before running testsUpdated tests: Account for the additional platform detection call in mocked executors
Test plan
🤖 Generated with Claude Code