MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / selectBootedIphoneUdid

Function selectBootedIphoneUdid

scripts/bench/agent-control-benchmark.mjs:1046–1089  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1044}
1045
1046function selectBootedIphoneUdid() {
1047 const result = run(simdeckBin, ["list", "--format", "compact-json"], {
1048 timeoutMs: 15000,
1049 });
1050 if (!result.ok) {
1051 return null;
1052 }
1053 const parsed = JSON.parse(result.stdout);
1054 const simulators = Array.isArray(parsed.simulators) ? parsed.simulators : [];
1055 const candidates = simulators.filter(
1056 (simulator) =>
1057 simulator.isBooted &&
1058 String(simulator.deviceTypeName || simulator.name || "").includes(
1059 "iPhone",
1060 ) &&
1061 String(simulator.runtimeName || "").includes("iOS"),
1062 );
1063 for (const simulator of candidates) {
1064 run(simdeckBin, ["launch", simulator.udid, settingsBundleId], {
1065 timeoutMs: 15000,
1066 allowFailure: true,
1067 });
1068 const snapshot = run(
1069 simdeckBin,
1070 [
1071 "describe",
1072 simulator.udid,
1073 "--format",
1074 "agent",
1075 "--max-depth",
1076 "8",
1077 "-i",
1078 ],
1079 { timeoutMs: 15000, allowFailure: true },
1080 );
1081 if (snapshot.stdout.includes(screenTimeId)) {
1082 return simulator.udid;
1083 }
1084 }
1085 return (
1086 candidates[0]?.udid ||
1087 simulators.find((simulator) => simulator.isBooted)?.udid
1088 );
1089}
1090
1091function currentScreenSize() {
1092 const result = run(

Callers 1

mainFunction · 0.85

Calls 2

runFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected