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

Function readXcodeIdeState

src/utils/xcode-state-reader.ts:233–271  ·  view source on GitHub ↗
(ctx: XcodeStateReaderContext)

Source from the content-addressed store, hash-verified

231}
232
233export async function readXcodeIdeState(ctx: XcodeStateReaderContext): Promise<XcodeStateResult> {
234 try {
235 const xcuserstatePath = await findXcodeStateFile(ctx);
236 if (!xcuserstatePath) {
237 return { error: 'No Xcode project/workspace found in working directory' };
238 }
239
240 const state = parseXcuserstate(xcuserstatePath);
241
242 const result: XcodeStateResult = {};
243
244 if (state.scheme) {
245 result.scheme = state.scheme;
246 log('info', `[xcode-state] Detected active scheme: ${state.scheme}`);
247 }
248
249 if (state.simulatorId) {
250 result.simulatorId = state.simulatorId;
251
252 const name = await lookupSimulatorName(ctx, state.simulatorId);
253 if (name) {
254 result.simulatorName = name;
255 log('info', `[xcode-state] Detected active simulator: ${name} (${state.simulatorId})`);
256 } else {
257 log('info', `[xcode-state] Detected active destination: ${state.simulatorId}`);
258 }
259 }
260
261 if (!result.scheme && !result.simulatorId) {
262 return { error: 'Could not extract active scheme or destination from Xcode state' };
263 }
264
265 return result;
266 } catch (e) {
267 const message = e instanceof Error ? e.message : String(e);
268 log('warn', `[xcode-state] Failed to read Xcode IDE state: ${message}`);
269 return { error: message };
270 }
271}

Callers 4

bootstrapServerFunction · 0.90

Calls 4

parseXcuserstateFunction · 0.90
logFunction · 0.90
findXcodeStateFileFunction · 0.85
lookupSimulatorNameFunction · 0.85

Tested by

no test coverage detected