From 2e65cd92cde1d0fcdad08ad7daa9b97ccfced9ba Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Fri, 9 Jan 2026 19:51:13 +0000 Subject: [PATCH] Fix: Use Xcode diagnostic format patterns to avoid false positive error counts The previous regex patterns matched "error:" and "warning:" with word boundaries, which caused false positives from: - Objective-C method parameters like error:(NSError**)error - Code snippets in warning messages containing method signatures Updated patterns now match only: - file:line:column: error: (typical compiler diagnostic format) - ^error: at start of line (standalone errors like linker errors) This prevents false positives while catching all actual Xcode build errors. Fixes #2 Co-authored-by: Andrew Benson --- xcode_mcp_server/utils/xcresult.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/xcode_mcp_server/utils/xcresult.py b/xcode_mcp_server/utils/xcresult.py index 045633a..58562eb 100644 --- a/xcode_mcp_server/utils/xcresult.py +++ b/xcode_mcp_server/utils/xcresult.py @@ -321,9 +321,12 @@ def extract_build_errors_and_warnings(build_log: str, """ Extract and format errors and warnings from a build log using regex pattern matching. - Uses word-boundary regex patterns (\\berror\\s*: and \\bwarning\\s*:) to match compiler - errors and warnings while avoiding false positives from phrases like "error-free" or - "no errors detected". + Uses Xcode diagnostic format patterns to match compiler errors and warnings: + - file:line:column: error: (typical compiler output) + - ^error: at start of line (standalone errors like linker errors) + + This avoids false positives from Objective-C method signatures like error:(NSError**)error + and code snippets in warning messages. Writes the complete unfiltered build log to /tmp/xcode-mcp-server/logs/build-{hash}.txt for full analysis. @@ -381,10 +384,12 @@ def extract_build_errors_and_warnings(build_log: str, error_lines = [] warning_lines = [] - # Pattern for compiler errors/warnings: matches "error:" or "warning:" at word boundaries - # This avoids false positives from phrases like "error-free" or "no errors" - error_pattern = re.compile(r'\berror\s*:', re.IGNORECASE) - warning_pattern = re.compile(r'\bwarning\s*:', re.IGNORECASE) + # Pattern for compiler errors/warnings in Xcode diagnostic format: + # - file:line:column: error: message (typical compiler output) + # - ^error: at start of line (standalone errors like linker errors) + # This avoids false positives from Objective-C method signatures like "error:(NSError**)error" + error_pattern = re.compile(r'(:\d+:\d+: error:)|(^error\s*:)', re.IGNORECASE | re.MULTILINE) + warning_pattern = re.compile(r'(:\d+:\d+: warning:)|(^warning\s*:)', re.IGNORECASE | re.MULTILINE) # Single iteration through output lines to extract errors/warnings for line in output_lines: