From 9afdfc7d560d138afa6f64c5770032ffa8b6e497 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 17 Jan 2026 16:06:53 +0000 Subject: [PATCH] Fix xcodemake argument corruption from overly broad string replacement The executeXcodemakeCommand function was using .replace() to remove project directory paths from arguments, which would corrupt any argument containing the project directory path as a substring (not just as a prefix). Changed to use .startsWith() and .substring() to only remove the project directory when it appears as a path prefix, matching the approach already used in doesMakeLogFileExist. Fixes XCODEBUILD-MCP-12S9 --- CHANGELOG.md | 1 + src/utils/xcodemake.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19cf8bc0..f6d309de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Fixed - Update UI automation guard guidance to point at `debug_continue` when paused. - Fix tool loading bugs in static tool registration. +- Fix xcodemake command argument corruption when project directory path appears as substring in non-path arguments. ## [1.16.0] - 2025-12-30 - Remove dynamic tool discovery (`discover_tools`) and `XCODEBUILDMCP_DYNAMIC_TOOLS`. Use `XCODEBUILDMCP_ENABLED_WORKFLOWS` to limit startup tool registration. diff --git a/src/utils/xcodemake.ts b/src/utils/xcodemake.ts index 00a46f39..e0e817ac 100644 --- a/src/utils/xcodemake.ts +++ b/src/utils/xcodemake.ts @@ -210,8 +210,14 @@ export async function executeXcodemakeCommand( const xcodemakeCommand = [getXcodemakeCommand(), ...buildArgs]; - // Remove projectDir from arguments - const command = xcodemakeCommand.map((arg) => arg.replace(projectDir + '/', '')); + // Remove projectDir from arguments if present at the start + const prefix = projectDir + '/'; + const command = xcodemakeCommand.map((arg) => { + if (arg.startsWith(prefix)) { + return arg.substring(prefix.length); + } + return arg; + }); return getDefaultCommandExecutor()(command, logPrefix); }