Skip to content

fix: boot and focus simulators via Device Hub URL scheme on Xcode 27+ - #262

Merged
cb1kenobi merged 1 commit into
mainfrom
feat/xcode-27-devicehub-launch
Aug 26, 2026
Merged

fix: boot and focus simulators via Device Hub URL scheme on Xcode 27+#262
cb1kenobi merged 1 commit into
mainfrom
feat/xcode-27-devicehub-launch

Conversation

@hansemannn

Copy link
Copy Markdown
Contributor

Follow-up to #260.

Why

Device Hub (the Simulator app replacement on Xcode 27+) ignores the legacy -CurrentDeviceUDID argument and does not boot any simulator on launch. Spawning it the old way neither boots nor selects the requested device — launches only worked when Device Hub happened to be running already (that path boots via simctl), and even then only the app itself was focused, never the requested device.

How

  • Boot + select: on Device Hub, boot the simulator via simctl boot, then open the device's window using Device Hub's devices://device/open?id=<udid> URL scheme, invoked as open -a <DeviceHub.app> <url> so the Device Hub of the selected Xcode handles it. A failure to open the window is not fatal (the simulator keeps running headless).
  • Focus: focus the device window via the same URL scheme instead of sim_focus.scpt, which can only activate the Device Hub app itself.
  • Process detection: isSimulatorRunning now matches Device Hub by its executable path, since it hosts all simulators in a single instance and is not necessarily launched with a -CurrentDeviceUDID argument (e.g. when the user opened it manually).

Older Xcodes are unaffected; the legacy spawn path is unchanged and the boot-wait loop is shared.

Note: the devices:// scheme is undocumented — Apple's own Instruments (Devices.xrplugin) uses it internally, and neither simctl nor devicectl offers a public equivalent for showing a device window. If it ever stops working, behavior degrades to a booted simulator without a focused window.

Test

Verified live against Xcode 27 Beta 5 through ioslib.simulator.launch:

  • cold launch (Device Hub not running): boots, launches Device Hub, opens + focuses the device window
  • killIfRunning: true: running Device Hub is found by path, killed, and relaunched cleanly
  • killIfRunning: false with booted device: instance and device reused, window focused
  • test-xcode suite passes (4/4); the test-simulator launch tests fail on main too due to hardcoded machine-specific UDIDs

…n Xcode 27+

Device Hub (the Simulator app replacement on Xcode 27+) ignores the legacy
-CurrentDeviceUDID argument and does not boot any simulator on launch, so
spawning it the old way neither boots nor selects the requested device.

- boot the simulator via `simctl boot` and open its window in Device Hub
  using the (undocumented) `devices://device/open?id=<udid>` URL scheme,
  opened via `open -a <DeviceHub.app>` so the Device Hub of the selected
  Xcode handles it; a failure to open the window is not fatal
- focus the simulator window via the same URL scheme instead of the
  sim_focus script, which can only activate the Device Hub app itself
- detect a running Device Hub by its executable path in the process list,
  since it hosts all simulators in a single instance and is not
  necessarily launched with a -CurrentDeviceUDID argument
@hansemannn
hansemannn requested a review from cb1kenobi August 23, 2026 15:47
@hansemannn

Copy link
Copy Markdown
Contributor Author

@cb1kenobi Tested it already, works great!

@cb1kenobi cb1kenobi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and I agree!

@cb1kenobi
cb1kenobi merged commit be01ee2 into main Aug 26, 2026
5 checks passed
@cb1kenobi
cb1kenobi deleted the feat/xcode-27-devicehub-launch branch August 26, 2026 03:32
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.

2 participants