Skip to content

fix: select architecture-appropriate Xcode build (fixes #456)#470

Open
wmehanna wants to merge 1 commit intoXcodesOrg:mainfrom
wmehanna:fix/architecture-aware-xcode-selection
Open

fix: select architecture-appropriate Xcode build (fixes #456)#470
wmehanna wants to merge 1 commit intoXcodesOrg:mainfrom
wmehanna:fix/architecture-aware-xcode-selection

Conversation

@wmehanna
Copy link
Copy Markdown

Summary

  • Add architectures field to Xcode model to capture build architecture from xcodereleases.com/data.json
  • Add currentHostArchitecture to detect host CPU via uname -m
  • Add firstCompatible(withVersion:hostArchitecture:) selection that prefers Universal > matching arch > first match

Problem

xcodereleases.com/data.json contains multiple entries per version:

  • Xcode (Apple Silicon) with architectures: ["arm64"]
  • Xcode (Universal) with architectures: ["arm64", "x86_64"]

Previously first(withVersion:) returned the first match regardless of architecture, causing Intel Macs to download arm64-only builds (issue #456).

Solution

firstCompatible(withVersion:hostArchitecture:) uses selection priority:

  1. Universal build (contains both arm64 and x86_64)
  2. Architecture-specific build matching host
  3. First match (fallback)

Changes

File Change
Models.swift Add architectures: [String]? field
XcodeList.swift Capture architectures from JSON via local XcodeReleaseEntry type
Environment.swift Add currentHostArchitecture via uname -m
Models+FirstWithVersion.swift Add firstCompatible(withVersion:hostArchitecture:)
XcodeInstaller.swift Use firstCompatible instead of first
Models+FirstWithVersionTests.swift Add tests for architecture selection

Testing

New tests verify:

  • Universal preferred on both arm64 and x86_64 hosts
  • Falls back to matching architecture when no Universal
  • Falls back to first match when no architecture info

Closes #456

xcodereleases.com/data.json contains multiple builds per version:
- Universal (arm64 + x86_64)
- Apple Silicon (arm64 only)

Previously first(withVersion:) returned first match regardless of
architecture, causing Intel Macs to download arm64-only builds.

Now firstCompatible(withVersion:hostArchitecture:) prefers:
1. Universal build (both architectures)
2. Architecture-specific build matching host
3. First match (fallback)

Fixes XcodesOrg#456
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.

Installing Xcode 26.2 on macOS Intel actually installed the Silicon version

1 participant