Skip to content

Commit 9afdfc7

Browse files
committed
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
1 parent f5037ce commit 9afdfc7

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
### Fixed
1515
- Update UI automation guard guidance to point at `debug_continue` when paused.
1616
- Fix tool loading bugs in static tool registration.
17+
- Fix xcodemake command argument corruption when project directory path appears as substring in non-path arguments.
1718

1819
## [1.16.0] - 2025-12-30
1920
- Remove dynamic tool discovery (`discover_tools`) and `XCODEBUILDMCP_DYNAMIC_TOOLS`. Use `XCODEBUILDMCP_ENABLED_WORKFLOWS` to limit startup tool registration.

src/utils/xcodemake.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,14 @@ export async function executeXcodemakeCommand(
210210

211211
const xcodemakeCommand = [getXcodemakeCommand(), ...buildArgs];
212212

213-
// Remove projectDir from arguments
214-
const command = xcodemakeCommand.map((arg) => arg.replace(projectDir + '/', ''));
213+
// Remove projectDir from arguments if present at the start
214+
const prefix = projectDir + '/';
215+
const command = xcodemakeCommand.map((arg) => {
216+
if (arg.startsWith(prefix)) {
217+
return arg.substring(prefix.length);
218+
}
219+
return arg;
220+
});
215221

216222
return getDefaultCommandExecutor()(command, logPrefix);
217223
}

0 commit comments

Comments
 (0)