fix: boot and focus simulators via Device Hub URL scheme on Xcode 27+ - #262
Merged
Conversation
…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
Contributor
Author
|
@cb1kenobi Tested it already, works great! |
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.
Follow-up to #260.
Why
Device Hub (the Simulator app replacement on Xcode 27+) ignores the legacy
-CurrentDeviceUDIDargument 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 viasimctl), and even then only the app itself was focused, never the requested device.How
simctl boot, then open the device's window using Device Hub'sdevices://device/open?id=<udid>URL scheme, invoked asopen -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).sim_focus.scpt, which can only activate the Device Hub app itself.isSimulatorRunningnow matches Device Hub by its executable path, since it hosts all simulators in a single instance and is not necessarily launched with a-CurrentDeviceUDIDargument (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.
Test
Verified live against Xcode 27 Beta 5 through
ioslib.simulator.launch:killIfRunning: true: running Device Hub is found by path, killed, and relaunched cleanlykillIfRunning: falsewith booted device: instance and device reused, window focusedtest-xcodesuite passes (4/4); thetest-simulatorlaunch tests fail onmaintoo due to hardcoded machine-specific UDIDs