/** * Thin wrappers around `xcrun simctl` for booting, installing, and launching * iOS apps on the iOS Simulator. Used by `bootAndLaunchForLeakInvestigation` * to set up a leak-investigation environment with `MallocStackLogging=1`. * * Design notes: * - All operations are idempotent where possible (boot ignores "already booted", * launch uses --terminate-running-process to atomically replace any prior instance). * - Env vars are propagated to the child via the `SIMCTL_CHILD_*` prefix * convention enforced by simctl. The caller passes plain `MallocStackLogging=1` * and we prefix it before invoking simctl. */ export interface SimulatorDevice { udid: string; name: string; state: "Booted" | "Shutdown" | string; /** OS runtime, e.g. "iOS 17.5" or "iOS-17-5". */ runtime: string; } /** * Find the first booted simulator. Returns null when none are booted. * Used as a fallback when the caller doesn't specify a simulator. */ export declare function findBootedSimulator(): Promise; /** * Find a simulator by display name (e.g. "iPhone 15"), optionally constrained * to a runtime version. Returns null when no match. * * @param os Either "latest" (highest available runtime), an explicit version * like "17.5", or undefined (any runtime). */ export declare function findSimulatorByName(name: string, os?: string): Promise; /** * Boot a simulator. Idempotent: if the device is already booted, returns * cleanly. Then waits via `simctl bootstatus -b` until SpringBoard is ready, * which prevents flaky `install` calls right after boot. */ export declare function bootSimulator(udid: string): Promise; /** * Install (or reinstall) an app bundle on a simulator. Idempotent by design; * simctl overwrites a prior install at the same bundle identifier. */ export declare function installApp(udid: string, appPath: string): Promise; export interface LaunchAppResult { /** Simulator-internal PID printed by simctl (NOT the host PID). */ simPid: number; bundleId: string; } /** * Launch an app on a booted simulator with the given env vars and launch args. * Uses `--terminate-running-process` so any existing instance is replaced * atomically (no race where stale env vars persist). * * Env vars are propagated to the child via the `SIMCTL_CHILD_*` prefix that * simctl honors. Pass plain keys (e.g. `MallocStackLogging`); we prefix. */ export declare function launchApp(udid: string, bundleId: string, env?: Record, launchArgs?: string[]): Promise; /** * Take a screenshot of the simulator's screen and write it to `outputPath`. * Wraps `xcrun simctl io screenshot `. */ export declare function takeScreenshot(udid: string, outputPath: string): Promise; /** Pure: parse the simulator-internal PID from `simctl launch` stdout. Exposed for tests. */ export declare function parseLaunchPid(stdout: string, bundleId: string): number | null; /** Pure: parse a `simctl list devices --json` payload into a flat list. Exposed for tests. */ export declare function parseSimctlDevices(stdout: string): SimulatorDevice[]; /** Pure: produce a sortable numeric key from a runtime identifier. */ export declare function runtimeSortKey(runtime: string): number;