feat(install): architecture-specific Xcode installs with safe force-reinstall rollback by arietis · Pull Request #464 · XcodesOrg/xcodes

added 4 commits

February 27, 2026 14:50
Adds an --architecture flag to the install command, allowing users to
select between apple-silicon, universal, or any variants.

This feature leverages metadata from the xcodereleases.com data source
to filter downloads when multiple architecture variants exist for the
same version. It includes validation to ensure the flag is used with
explicit versions and the correct data source.
Replaces string-based architecture handling with a dedicated
`XcodeDistributionArchitecture` enum and Set-based collections.

This ensures only valid architectures are processed and simplifies
comparison logic by eliminating manual string normalization and
sorting. This change makes the code more robust against malformed
metadata and provides a clearer domain model for Xcode downloads.
Adds a flag to allow overwriting an existing Xcode installation. This
is necessary to support switching between different architecture
variants of the same version or repairing a damaged installation.

Updated error handling to provide clearer feedback when an architecture
mismatch requires a forced reinstall.
Implements a backup and restore mechanism when using --force-reinstall.
Previously, the existing version was deleted immediately. Now, it is
moved to a temporary location and restored if the installation fails,
preventing users from being left without a functional Xcode.

Also ensures the percentage formatter uses a stable locale and adds
comprehensive tests for the new rollback logic and CLI flags.