diff --git a/.changeset/thirty-worlds-invent.md b/.changeset/thirty-worlds-invent.md new file mode 100644 index 000000000..abf82c9a1 --- /dev/null +++ b/.changeset/thirty-worlds-invent.md @@ -0,0 +1,5 @@ +--- +'@rock-js/platform-apple-helpers': patch +--- + +Support launching Apple simulators through Device Hub in Xcode 27. diff --git a/packages/platform-apple-helpers/src/lib/commands/run/runOnSimulator.ts b/packages/platform-apple-helpers/src/lib/commands/run/runOnSimulator.ts index 76ad26d9d..58878d083 100644 --- a/packages/platform-apple-helpers/src/lib/commands/run/runOnSimulator.ts +++ b/packages/platform-apple-helpers/src/lib/commands/run/runOnSimulator.ts @@ -1,3 +1,4 @@ +import fs from 'node:fs'; import path from 'node:path'; import type { SubprocessError } from '@rock-js/tools'; import { color, logger, RockError, spawn, spinner } from '@rock-js/tools'; @@ -24,12 +25,18 @@ export async function launchSimulator(device: Device) { stdio: 'pipe', }); - await spawn('open', [ - `${activeDeveloperDir}/Applications/Simulator.app`, - '--args', - '-CurrentDeviceUDID', - device.udid, - ]); + const simulatorApp = path.join(activeDeveloperDir.trim(), 'Applications', 'Simulator.app'); + + if (fs.existsSync(simulatorApp)) { + await spawn('open', [ + simulatorApp, + '--args', + '-CurrentDeviceUDID', + device.udid, + ]); + } else { + await spawn('open', [`devices://device/open?id=${device.udid}`]); + } if (device.state !== 'Booted') { await bootSimulator(device);