Skip to content

Fix Xcode 26 beta 2 version detection failure#2

Open
davidbean-hash wants to merge 3 commits into
masterfrom
devin/1779287516-fix-xcode26-version-detection
Open

Fix Xcode 26 beta 2 version detection failure#2
davidbean-hash wants to merge 3 commits into
masterfrom
devin/1779287516-fix-xcode26-version-detection

Conversation

@davidbean-hash

@davidbean-hash davidbean-hash commented May 20, 2026

Copy link
Copy Markdown
Owner

Change Description:

Fixes ChargePoint#91 — xcparse fails with Xcode 26 beta 2 because Version.xcresulttool() cannot parse the new version format.

Changes:

  1. XCResultToolCommand.swift – When Version.xcresulttool() returns nil, shouldAddLegacyFlag now defaults to true instead of false. Uses Version.needsLegacyFlag() for version-aware comparison.

  2. Version+XCPTooling.swift – Made version parsing more robust:

    • Extracted parseXcresulttoolVersionOutput(_:) as a public testable method
    • Added manual dot-component parsing as a fallback when Version(string:) fails (handles formats like 26.0, 26.0.0)
    • Added a regex-based fallback that scans the full output for any version X.Y.Z or version X pattern
    • Added usesSemanticVersioning() to detect new Xcode 16+ version scheme (major < 100)
    • Added needsLegacyFlag() and supportsUnicodeExportPaths() helpers that handle both old (build number) and new (semantic) versioning schemes
  3. XCPParser.swift – Updated Unicode compatibility check to use Version.supportsUnicodeExportPaths() instead of raw comparison, fixing a regression where Version(26, 0, 0) < Version(15500, 0, 0) incorrectly disabled Unicode path support.

  4. Unit tests – Added XCParseCoreTests target with 21 tests covering:

    • Plain integer versions (e.g., 23028) and dotted versions (e.g., 26.0, 26.0.0)
    • Unparseable output returning nil
    • Version scheme detection (semantic vs build number)
    • needsLegacyFlag() for both schemes (Xcode 26 correctly needs legacy flag)
    • supportsUnicodeExportPaths() for both schemes (Xcode 26 correctly supports Unicode)
    • Fallback regex parsing, edge cases

Test Plan/Testing Performed:

  • All 25 version parsing + scheme detection tests pass (verified on Linux with Swift 5.9.2)
  • XCParseCore target builds successfully
  • Verified Xcode 26's Version(26, 0, 0) correctly:
    • Needs --legacy flag (via needsLegacyFlag)
    • Supports Unicode export paths (via supportsUnicodeExportPaths)
  • Old build-number versions still work correctly (15500, 23028, etc.)

Link to Devin session: https://app.devin.ai/sessions/3d7908cc7c164d0fa73749ce376539f3
Requested by: @davidbean-hash


Open in Devin Review

- Default shouldAddLegacyFlag to true when xcresulttool version cannot
  be determined, since newer Xcode versions that change the version
  format also require the --legacy flag
- Add more robust version parsing with fallback regex pattern to handle
  different version output formats (e.g. dotted versions like 26.0.0)

Fixes ChargePoint#91

Co-Authored-By: david.bean <david.bean@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

- Extract parseXcresulttoolVersionOutput() as a public testable method
- Add XCParseCoreTests target with VersionParsingTests covering:
  - Plain integer versions (e.g., 23028)
  - Dotted versions (e.g., 26.0, 26.0.0, 26.1.2)
  - Unparseable output returning nil
  - Fallback regex parsing
  - Legacy flag threshold comparisons
  - Edge cases (multiline, whitespace, comma-separated)

Co-Authored-By: david.bean <david.bean@cognition.ai>
devin-ai-integration[bot]

This comment was marked as resolved.

Xcode 16+ changed xcresulttool version output from large build numbers
(e.g. 15500, 23028) to semantic versions (e.g. 26.0). The previous
commit correctly parsed the new format but broke two comparisons:

1. shouldAddLegacyFlag: Version(26,0,0) >= Version(23028,0,0) was false,
   so --legacy flag was NOT added for Xcode 26 (the original bug)
2. Unicode export paths: Version(26,0,0) < Version(15500,0,0) was true,
   incorrectly marking Xcode 26 as not supporting Unicode paths

Fix: Add usesSemanticVersioning() to detect the new scheme (major < 100),
and needsLegacyFlag()/supportsUnicodeExportPaths() helpers that handle
both schemes correctly. Update XCResultToolCommand.swift and XCPParser.swift
to use these helpers instead of raw comparisons.

Credit: Issue identified by Devin Review automated analysis.
Co-Authored-By: david.bean <david.bean@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

Test Results — Xcode 26 Version Detection Fix

Environment: Ubuntu 22.04, Swift 5.9.2 | Devin Session

Note: All testing is shell-only (swift build + test script). swift test cannot run on Linux because the xcparse executable target requires macOS CoreServices. Full test suite requires macOS CI.

Results: 25/25 passed

# Test Result
1 XCParseCore + XCParseCoreTests build PASSED
2 Parse plain integer 23028 (regression) PASSED
3 Parse dotted 26.0 (core bug fix) PASSED
4 Parse 26.1.2 (all components preserved) PASSED
5 Unparseable output → nil PASSED
6 Version scheme detection (usesSemanticVersioning) PASSED
7 needsLegacyFlag(26.0.0) → true (CRITICAL) PASSED
8 needsLegacyFlag old scheme regression PASSED
9 supportsUnicodeExportPaths(26.0.0) → true (Devin Review fix) PASSED
10 supportsUnicodeExportPaths old scheme regression PASSED
11 Git diff shows all 5 expected files changed PASSED
Full test output
=== Version Parsing Tests ===

-- Test 2: Plain integer version (regression) --
  PASS: Plain integer with format info
  PASS: Plain integer without trailing info

-- Test 3: Dotted version 26.0 (core bug fix) --
  PASS: Two-component dotted version (Xcode 26 format)
  PASS: Three-component dotted version

-- Test 4: Three-component with non-zero parts --
  PASS: All three components preserved
  PASS: Two-component with non-zero minor

-- Test 5: Unparseable output returns nil --
  PASS: Empty string → nil
  PASS: Garbage → nil
  PASS: Non-numeric → nil

-- Test 6: Version scheme detection --
  PASS: 26.0.0 is semantic (new scheme)
  PASS: 16.0.0 is semantic (new scheme)
  PASS: 15500 is NOT semantic (old scheme)
  PASS: 23028 is NOT semantic (old scheme)

-- Test 7: needsLegacyFlag — Xcode 26 NEEDS legacy (CRITICAL) --
  PASS: Xcode 26 (new scheme) NEEDS legacy
  PASS: Xcode 16 (new scheme) NEEDS legacy

-- Test 8: needsLegacyFlag — old scheme regression --
  PASS: Old scheme >= threshold needs legacy
  PASS: Old scheme < threshold does NOT need legacy

-- Test 9: supportsUnicodeExportPaths — Xcode 26 (Devin Review fix) --
  PASS: Xcode 26 (new scheme) SUPPORTS Unicode

-- Test 10: supportsUnicodeExportPaths — old scheme regression --
  PASS: Old scheme >= threshold supports Unicode
  PASS: Old scheme < threshold does NOT support Unicode

-- Fallback regex parsing --
  PASS: Fallback regex with different prefix
  PASS: Fallback regex with dotted version

-- Edge cases --
  PASS: Multiline output with version on second line
  PASS: Extra whitespace
  PASS: Commas separating components

=== Results: 25 passed, 0 failed ===
Files changed
 Package.swift                                    |   3 +
 Sources/XCParseCore/Version+XCPTooling.swift     |  98 +++++++++---
 Sources/XCParseCore/XCResultToolCommand.swift    |   6 +-
 Sources/xcparse/XCPParser.swift                  |   4 +-
 Tests/XCParseCoreTests/VersionParsingTests.swift | 181 +++++++++++++++++++++++
 5 files changed, 266 insertions(+), 26 deletions(-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Error when using Xcode 26 beta 2 tools

1 participant