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

Function executeXcodeBuildCommand

src/utils/build-utils.ts:29–264  ·  view source on GitHub ↗
(
  params: SharedBuildParams,
  platformOptions: PlatformBuildOptions,
  preferXcodebuild: boolean = false,
  buildAction: string = 'build',
  executor: CommandExecutor,
  execOpts?: CommandExecOptions,
  pipeline?: XcodebuildPipeline,
)

Source from the content-addressed store, hash-verified

27}
28
29export async function executeXcodeBuildCommand(
30 params: SharedBuildParams,
31 platformOptions: PlatformBuildOptions,
32 preferXcodebuild: boolean = false,
33 buildAction: string = 'build',
34 executor: CommandExecutor,
35 execOpts?: CommandExecOptions,
36 pipeline?: XcodebuildPipeline,
37): Promise<BuildCommandResult> {
38 function addBuildMessage(message: string, level: 'info' | 'success' = 'info'): void {
39 pipeline?.emitFragment(
40 createNoticeFragment('BUILD', message.replace(/^[^\p{L}\p{N}]+/u, '').trim(), level),
41 );
42 }
43
44 log('info', `Starting ${platformOptions.logPrefix} ${buildAction} for scheme ${params.scheme}`);
45
46 const isXcodemakeEnabledFlag = isXcodemakeEnabled();
47 let xcodemakeAvailableFlag = false;
48
49 if (isXcodemakeEnabledFlag && buildAction === 'build') {
50 xcodemakeAvailableFlag = await isXcodemakeAvailable();
51
52 if (xcodemakeAvailableFlag && preferXcodebuild) {
53 log(
54 'info',
55 'xcodemake is enabled but preferXcodebuild is set to true. Falling back to xcodebuild.',
56 );
57 addBuildMessage(
58 '⚠️ incremental build support is enabled but preferXcodebuild is set to true. Falling back to xcodebuild.',
59 );
60 } else if (!xcodemakeAvailableFlag) {
61 addBuildMessage('⚠️ xcodemake is enabled but not available. Falling back to xcodebuild.');
62 log('info', 'xcodemake is enabled but not available. Falling back to xcodebuild.');
63 } else {
64 log('info', 'xcodemake is enabled and available, using it for incremental builds.');
65 addBuildMessage('ℹ️ xcodemake is enabled and available, using it for incremental builds.');
66 }
67 }
68
69 const useXcodemake =
70 isXcodemakeEnabledFlag &&
71 xcodemakeAvailableFlag &&
72 buildAction === 'build' &&
73 !preferXcodebuild;
74
75 try {
76 const command = ['xcodebuild'];
77 const workspacePath = params.workspacePath
78 ? resolvePathFromCwd(params.workspacePath)
79 : undefined;
80 const projectPath = params.projectPath ? resolvePathFromCwd(params.projectPath) : undefined;
81 const derivedDataPath = resolveEffectiveDerivedDataPath({
82 derivedDataPath: params.derivedDataPath,
83 workspacePath,
84 projectPath,
85 });
86

Callers 9

createTestExecutorFunction · 0.90
createCleanExecutorFunction · 0.90
createBuildMacOSExecutorFunction · 0.90
createBuildSimExecutorFunction · 0.90

Calls 15

logFunction · 0.90
isXcodemakeEnabledFunction · 0.90
isXcodemakeAvailableFunction · 0.90
resolvePathFromCwdFunction · 0.90
doesMakefileExistFunction · 0.90
doesMakeLogFileExistFunction · 0.90
executeMakeCommandFunction · 0.90
executeXcodemakeCommandFunction · 0.90
addBuildMessageFunction · 0.85

Tested by

no test coverage detected