MCPcopy Index your code
hub / github.com/callstack/agent-device / getSimulatorState

Function getSimulatorState

src/platforms/apple/core/simulator.ts:248–273  ·  view source on GitHub ↗
(deviceOrUdid: DeviceInfo | string)

Source from the content-addressed store, hash-verified

246}
247
248export async function getSimulatorState(deviceOrUdid: DeviceInfo | string): Promise<string | null> {
249 const udid = typeof deviceOrUdid === 'string' ? deviceOrUdid : deviceOrUdid.id;
250 const simctlArgs =
251 typeof deviceOrUdid === 'string'
252 ? buildSimctlArgs(['list', 'devices', '-j'])
253 : buildSimctlArgsForDevice(deviceOrUdid, ['list', 'devices', '-j']);
254 const result = await runXcrun(simctlArgs, {
255 allowFailure: true,
256 timeoutMs: IOS_SIMCTL_LIST_TIMEOUT_MS,
257 });
258 if (result.exitCode !== 0) return null;
259
260 try {
261 const payload = JSON.parse(String(result.stdout ?? '')) as {
262 devices: Record<string, { udid: string; state: string }[]>;
263 };
264
265 for (const runtime of Object.values(payload.devices ?? {})) {
266 const match = runtime.find((entry) => entry.udid === udid);
267 if (match) return match.state;
268 }
269 return null;
270 } catch {
271 return null;
272 }
273}

Callers 3

getFinalSimulatorStateFunction · 0.90
openIosDeviceFunction · 0.90
ensureBootedSimulatorFunction · 0.85

Calls 5

buildSimctlArgsFunction · 0.90
buildSimctlArgsForDeviceFunction · 0.90
runXcrunFunction · 0.90
valuesMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected