MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / lookupSimulatorName

Function lookupSimulatorName

src/utils/xcode-state-reader.ts:197–231  ·  view source on GitHub ↗
(
  ctx: XcodeStateReaderContext,
  simulatorId: string,
)

Source from the content-addressed store, hash-verified

195}
196
197export async function lookupSimulatorName(
198 ctx: XcodeStateReaderContext,
199 simulatorId: string,
200): Promise<string | undefined> {
201 const { executor } = ctx;
202
203 const result = await executor(
204 ['xcrun', 'simctl', 'list', 'devices', 'available', '--json'],
205 'List simulators',
206 false,
207 );
208
209 if (!result.success) {
210 log('warn', `[xcode-state] Failed to list simulators: ${result.error}`);
211 return undefined;
212 }
213
214 try {
215 const data = JSON.parse(result.output) as {
216 devices: Record<string, Array<{ udid: string; name: string }>>;
217 };
218
219 for (const runtime of Object.values(data.devices)) {
220 for (const device of runtime) {
221 if (device.udid === simulatorId) {
222 return device.name;
223 }
224 }
225 }
226 } catch (e) {
227 log('warn', `[xcode-state] Failed to parse simulator list: ${e}`);
228 }
229
230 return undefined;
231}
232
233export async function readXcodeIdeState(ctx: XcodeStateReaderContext): Promise<XcodeStateResult> {
234 try {

Callers 3

processFileChangeFunction · 0.90
readXcodeIdeStateFunction · 0.85

Calls 2

logFunction · 0.90
executorFunction · 0.50

Tested by

no test coverage detected