XcodeBuildMCP icon indicating copy to clipboard operation
XcodeBuildMCP copied to clipboard

[Bug]: Cannot run individual tests when using Swift Testing

Open mattcorey opened this issue 7 months ago • 0 comments

Bug Description

There is a bug in Apple's xcodebuild tool (at least up to Xcode 16.4 - I can't yet test with Xcode 26) that forces users to use '()()' at the end of test identifiers when using Swift Testing. A description of the issue can be found here: https://trinhngocthuyen.com/posts/tech/swift-testing-and-xcodebuild/

When attempting to run an individual Swift Testing test using xcodebuild-mcp, it appears to be filtering out the '()' characters, and produces the following error:

Error: ❌ [stderr] sh: -c: line 0: syntax error near unexpected token ('`

Unfortunately, these characters are now necessary with Swift Testing, meaning that xcodebuild-mcp can't work with modern tests (assuming there isn't some work around I'm not aware of)

NOTE: Even if Apple eventually does fix this issue in xcodebuild, as long as they still require '()' at the end of the test identifiers for these tests, having this syntax enforcement will prevent the mcp server from working

Debug Output

xcodebuild-mcp:test_sim_name_proj (MCP)(projectPath: "/Users/mattcorey/Developer/BrainstormAI/BrainstormAI.xcodeproj", scheme: "BrainstormAI", simulatorName: "iPhone 16 Pro", extraArgs: ["-only-testing:BrainstormAITests/VersionIntegrationTests/testAddChildNodeDiff()()"]) ⎿  Error: ❌ [stderr] sh: -c: line 0: syntax error near unexpected token `('

Editor/Client

Claude Code 1.0.40

MCP Server Version

'latest' as of 7/2/25 (1.10.4, I believe)

LLM

Claude

MCP Configuration

"xcodebuild-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "xcodebuildmcp@latest"
      ],
      "env": {}
    }

Steps to Reproduce

Me:

Can you try running that test using the MCP server? I want to see if that works

Claude Code: ⏺ I'll run the test using the MCP xcodebuild server to see if it works properly.

⏺ xcodebuild-mcp:test_sim_name_proj (MCP)(projectPath: "/Users/mattcorey/Developer/BrainstormAI/BrainstormAI.xcodeproj", scheme: "BrainstormAI", simulatorName: "iPhone 16 Pro", extraArgs: ["-only-testing:BrainstormAITests/VersionIntegrationTests/testAddChildNodeDiff()()"]) ⎿  Error: ❌ [stderr] sh: -c: line 0: syntax error near unexpected token `('

Expected Behavior

The server now needs to allow the use of '()' characters (Specifically '()()', but it probably shouldn't assume Apple's bug won't eventually get fixed) on the '-only-testing' flag

Actual Behavior

Error: ❌ [stderr] sh: -c: line 0: syntax error near unexpected token `('

Error Messages

Error: ❌ [stderr] sh: -c: line 0: syntax error near unexpected token `('

mattcorey avatar Jul 02 '25 15:07 mattcorey