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

Function selectSimulator

src/cli/commands/setup.ts:559–611  ·  view source on GitHub ↗
(opts: {
  existingSimulatorId?: string;
  existingSimulatorName?: string;
  platformFilter: SetupPlatform[];
  executor: CommandExecutor;
  prompter: Prompter;
  isTTY: boolean;
  quietOutput: boolean;
})

Source from the content-addressed store, hash-verified

557}
558
559async function selectSimulator(opts: {
560 existingSimulatorId?: string;
561 existingSimulatorName?: string;
562 platformFilter: SetupPlatform[];
563 executor: CommandExecutor;
564 prompter: Prompter;
565 isTTY: boolean;
566 quietOutput: boolean;
567}): Promise<ListedSimulator | null> {
568 const allSimulators = await withSpinner({
569 isTTY: opts.isTTY,
570 quietOutput: opts.quietOutput,
571 startMessage: 'Loading simulators...',
572 stopMessage: 'Simulators loaded.',
573 task: async () => {
574 try {
575 return await listSimulators(opts.executor);
576 } catch {
577 return [];
578 }
579 },
580 });
581 const simulators = filterSimulatorsByPlatforms(allSimulators, opts.platformFilter);
582
583 const defaultIndex =
584 simulators.length > 0
585 ? getDefaultSimulatorIndex(simulators, opts.existingSimulatorId, opts.existingSimulatorName)
586 : 0;
587
588 showPromptHelp(
589 'Select a simulator to set the default device target used by simulator commands.',
590 opts.quietOutput,
591 );
592 return opts.prompter.selectOne({
593 message: 'Select a simulator',
594 options: [
595 {
596 value: null,
597 label: 'No default simulator',
598 description: 'Leave simulator commands unpinned during setup.',
599 },
600 ...simulators.map((simulator) => ({
601 value: simulator,
602 label: `${simulator.runtime} — ${simulator.name} (${simulator.udid})`,
603 description: simulator.state,
604 })),
605 ],
606 initialIndex:
607 simulators.length > 0 && (opts.existingSimulatorId ?? opts.existingSimulatorName) != null
608 ? defaultIndex + 1
609 : 0,
610 });
611}
612
613function requiresSimulatorDefault(enabledWorkflows: string[]): boolean {
614 return enabledWorkflows.some((workflowId) => SIMULATOR_DEFAULT_WORKFLOWS.has(workflowId));

Callers 1

collectSetupSelectionFunction · 0.85

Calls 6

listSimulatorsFunction · 0.90
withSpinnerFunction · 0.85
getDefaultSimulatorIndexFunction · 0.85
showPromptHelpFunction · 0.85
selectOneMethod · 0.80

Tested by

no test coverage detected