XcodeBuildMCP icon indicating copy to clipboard operation
XcodeBuildMCP copied to clipboard

[Bug]: [xcodemake] Parsing error in swift-collections

Open twocentstudios opened this issue 6 months ago • 4 comments

Bug Description

While testing out the incremental build feature, I got the following error related to the swift-collections package:

❌ [stderr] make: *** No rule to make target /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/SourcePackages/checkouts/swift-collections/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial', needed by /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/Build/Intermediates.noindex/swift-collections.build/Debug-iphonesimulator/OrderedCollections.build/Objects-normal/arm64/OrderedDictionary+Partial MutableCollection.o'.

o3 diagnosed the issue as a space parsing error and offered the following patch (with extraneous formatting and comments):

@@
-# regex for file path argument (handles spaces escaped with backslash)
-my $notSpace = "[^\\\\\\s]";
-$fileArg     = "$notSpace+(?:\\\\.$notSpace*)*";
+# regex for file path argument
+# – matches EITHER a quoted path ("... with spaces.swift")
+#   OR the traditional token where any spaces are backslash-escaped.
+my $notSpace = "[^\\\\\\s\"]";
+$fileArg     = "(?:\"[^\"]+\"|$notSpace+(?:\\\\.$notSpace*)*)";
@@
                 unescape("{}()", $make_target_object);
                 escape("\$& ",  $make_target_object);
                 dollarEscape($make_dep_source);
                 unescape("'",  $make_dep_source);
+                # -- NEW: normalise prerequisite path --------------------
+                #  • drop surrounding double-quotes if present
+                #  • escape any literal spaces ('$' and '&' already covered)
+                $make_dep_source =~ s/^"(.*)"$/$1/;
+                escape("\$& ",  $make_dep_source);
@@   # identical block appears three times (Swift, Clang, and Obj-C loops)
                 unescape("{}()", $make_target_object);
                 escape("\$& ",  $make_target_object);
                 dollarEscape($make_dep_source);
                 unescape("'",  $make_dep_source);
+                $make_dep_source =~ s/^"(.*)"$/$1/;
+                escape("\$& ",  $make_dep_source);
@@
                 unescape("{}()", $make_target_object);
                 escape("\$& ",  $make_target_object);
                 dollarEscape($make_dep_source);
                 unescape("'",  $make_dep_source);
+                $make_dep_source =~ s/^"(.*)"$/$1/;
+                escape("\$& ",  $make_dep_source);

I applied the patch and tested it with the existing build output .log file and it resolved the issue.

I compared against this version of cameroncooke/xcodemake.

Debug Output

N/A

Editor/Client

Cursor 1.0.0

MCP Server Version

1.8.0

LLM

N/A

MCP Configuration


Steps to Reproduce

  1. Create a template iOS app project in Xcode
  2. Add the swift-collections
  3. Open the project in Cursor with XcodeBuildMCP configured with INCREMENTAL_BUILDS_ENABLED env var.
  4. Ask Cursor to build the project with XcodeBuildMCP
  5. Verify a Makefile and .log file are generated in the project root directory
  6. Add a print statement somewhere in the project
  7. Ask Cursor to build the project with XcodeBuildMCP incrementally
  8. Verify tool call says ℹ️ Using make for incremental build
  9. Verify error message is shown related to OrderedDictionary+Partial

Expected Behavior

Tool call result should include:

✅ iOS Simulator Build build succeeded for scheme my-app-name.

Actual Behavior

Tool call includes error messages and falls back to a clean build:

❌ [stderr] make: *** No rule to make target `/Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/SourcePackages/checkouts/swift-collections/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial', needed by `/Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/Build/Intermediates.noindex/swift-collections.build/Debug-iphonesimulator/OrderedCollections.build/Objects-normal/arm64/OrderedDictionary+Partial MutableCollection.o'. Stop.

❌ iOS Simulator Build build failed for scheme my-app-name.

Error Messages

❌ [stderr] make: *** No rule to make target `/Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/SourcePackages/checkouts/swift-collections/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial', needed by `/Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/Build/Intermediates.noindex/swift-collections.build/Debug-iphonesimulator/OrderedCollections.build/Objects-normal/arm64/OrderedDictionary+Partial MutableCollection.o'. Stop.

❌ iOS Simulator Build build failed for scheme my-app-name.

twocentstudios avatar Jun 09 '25 09:06 twocentstudios

Thanks for the report and the investigation!

Would you mind opening this issue on my fork of xcodemake repo https://github.com/cameroncooke/xcodemake and then linking back to here?

Cameron.

On Mon, 9 Jun 2025 at 10:07, Chris Trott @.***> wrote:

twocentstudios created an issue (cameroncooke/XcodeBuildMCP#61) https://github.com/cameroncooke/XcodeBuildMCP/issues/61 Bug Description

While testing out the incremental build feature, I got the following error related to the swift-collections https://github.com/apple/swift-collections package:

❌ [stderr] make: *** No rule to make target /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/SourcePackages/checkouts/swift-collections/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial', needed by /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/Build/Intermediates.noindex/swift-collections.build/Debug-iphonesimulator/OrderedCollections.build/Objects-normal/arm64/OrderedDictionary+Partial MutableCollection.o'.

o3 diagnosed the issue https://chatgpt.com/share/68469fa5-2e8c-8009-bdac-ce379449717b as a space parsing error and offered the following patch (with extraneous formatting and comments):

@@-# regex for file path argument (handles spaces escaped with backslash)-my $notSpace = "[^\\\s]";-$fileArg = "$notSpace+(?:\\.$notSpace*)";+# regex for file path argument+# – matches EITHER a quoted path ("... with spaces.swift")+# OR the traditional token where any spaces are backslash-escaped.+my $notSpace = "[^\\\s"]";+$fileArg = "(?:"[^"]+"|$notSpace+(?:\\.$notSpace))"; @@ unescape("{}()", $make_target_object); escape("$& ", $make_target_object); dollarEscape($make_dep_source); unescape("'", $make_dep_source);+ # -- NEW: normalise prerequisite path --------------------+ # • drop surrounding double-quotes if present+ # • escape any literal spaces ('$' and '&' already covered)+ $make_dep_source =~ s/^"(.)"$/$1/;+ escape("$& ", $make_dep_source); @@ # identical block appears three times (Swift, Clang, and Obj-C loops) unescape("{}()", $make_target_object); escape("$& ", $make_target_object); dollarEscape($make_dep_source); unescape("'", $make_dep_source);+ $make_dep_source =~ s/^"(.)"$/$1/;+ escape("$& ", $make_dep_source); @@ unescape("{}()", $make_target_object); escape("$& ", $make_target_object); dollarEscape($make_dep_source); unescape("'", $make_dep_source);+ $make_dep_source =~ s/^"(.)"$/$1/;+ escape("$& ", $make_dep_source);

I applied the patch and tested it with the existing build output .log file and it resolved the issue.

I compared against this version of cameroncooke/xcodemake https://github.com/cameroncooke/xcodemake/blob/1749682a99794edc257010b3eaa35c39f0f91c50/xcodemake . Debug Output

N/A Editor/Client

Cursor 1.0.0 MCP Server Version

1.8.0 LLM

N/A MCP Configuration

Steps to Reproduce

  1. Create a template iOS app project in Xcode
  2. Add the swift-collections https://github.com/apple/swift-collections
  3. Open the project in Cursor with XcodeBuildMCP configured with INCREMENTAL_BUILDS_ENABLED env var.
  4. Ask Cursor to build the project with XcodeBuildMCP
  5. Verify a Makefile and .log file are generated in the project root directory
  6. Add a print statement somewhere in the project
  7. Ask Cursor to build the project with XcodeBuildMCP incrementally
  8. Verify tool call says ℹ️ Using make for incremental build
  9. Verify error message is shown related to OrderedDictionary+Partial

Expected Behavior

Tool call result should include:

✅ iOS Simulator Build build succeeded for scheme my-app-name.

Actual Behavior

Tool call includes error messages and falls back to a clean build:

❌ [stderr] make: *** No rule to make target /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/SourcePackages/checkouts/swift-collections/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial', needed by /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/Build/Intermediates.noindex/swift-collections.build/Debug-iphonesimulator/OrderedCollections.build/Objects-normal/arm64/OrderedDictionary+Partial MutableCollection.o'. Stop.

❌ iOS Simulator Build build failed for scheme my-app-name.

Error Messages

❌ [stderr] make: *** No rule to make target /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/SourcePackages/checkouts/swift-collections/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial', needed by /Users/c/Library/Developer/Xcode/DerivedData/my-app-name-hdhpknjobkgfcxerwaixgtsphmfo/Build/Intermediates.noindex/swift-collections.build/Debug-iphonesimulator/OrderedCollections.build/Objects-normal/arm64/OrderedDictionary+Partial MutableCollection.o'. Stop.❌ iOS Simulator Build build failed for scheme my-app-name.

— Reply to this email directly, view it on GitHub https://github.com/cameroncooke/XcodeBuildMCP/issues/61, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEZ6SM72UYEJX7XT6MR6KL3CVFE5AVCNFSM6AAAAAB64NDBFOVHI2DSMVQWIX3LMV43ASLTON2WKOZTGEZDSNRXGIZTGMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cameroncooke avatar Jun 09 '25 11:06 cameroncooke

That repo doesn't have public Issues yet (only PRs), but happy to once that happens.

twocentstudios avatar Jun 09 '25 11:06 twocentstudios

Apologies! I've enabled Issues!

cameroncooke avatar Jun 09 '25 11:06 cameroncooke

Done! 🚢 Feel free to close.

twocentstudios avatar Jun 09 '25 14:06 twocentstudios