Skip to content

fix(apple): preserve device order when grouping simulators - #2861

Open
xu1132 wants to merge 1 commit into
react-native-community:mainfrom
xu1132:fix/stable-device-order
Open

xu1132 wants to merge 1 commit into
react-native-community:mainfrom
xu1132:fix/stable-device-order

Conversation

@xu1132

@xu1132 xu1132 commented Sep 23, 2026

Copy link
Copy Markdown

Summary

listDevices groups physical devices before simulators using a comparator that only examines its first argument. It returns -1 even when both items are physical devices, reversing their input order. For example, three physical devices returned by xcdevice list as A, B, C are returned by the CLI as C, B, A.

Compare both simulator flags so physical devices still come first, while returning 0 for devices in the same group. This preserves their original order. Add four regression cases covering physical-only, simulator-only, and interleaved lists.

Test Plan

Validated with Node 22.16.0:

  • New regression cases on the original implementation: 3 failed, 4 passed in the device-list suite.
  • After the fix: 7 passed in the device-list suite, including existing iOS/tvOS filtering and metadata-merging tests.
  • Full package unit suite: 55 suites passed, 317 tests passed, 1 todo, 62 snapshots passed.
  • yarn build, including TypeScript declarations: passed.
  • yarn lint: passed with two existing warnings in unchanged files.
  • git diff --check: passed.

No physical-device or local React Native checkout integration test was performed; device discovery is mocked in these unit tests.

Checklist

  • Documentation is up to date (no public API or option changes).
  • Follows commit message convention described in CONTRIBUTING.md.
  • For functional changes, my test plan has linked these CLI changes into a local react-native checkout (instructions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants