$ show XcodesOrg/xcodes
Xcodes is a command-line tool for installing, managing, and switching between multiple versions of Apple's Xcode IDE. It provides subcommands for downloading, listing, selecting, uninstalling, and updating Xcode releases, as well as managing simulator runtimes. The tool supports two data sources: scraping Apple's Developer downloads page (the 'apple' source) and consuming the unofficial Xcode Releases JSON feed ('xcodeReleases'). Authentication is handled through Apple ID with two-factor or SMS fallback, or via fastlane session cookies. The architecture is a modular Swift Package Manager project with a thin CLI entry point (using Apple's ArgumentParser) and a core library (XcodesKit) that encapsulates all business logic. The core library uses a lightweight dependency injection pattern via an Environment struct, a strategy pattern for downloads (URLSession or aria2), and a service-oriented design for runtime installation, list management, and system configuration. The codebase exhibits strong Swift concurrency adoption and includes test fixtures for parsing Apple HTML and property-list data. While the Apple scraping approach is inherently fragile, the overall architecture is well-structured, testable, and follows modern Swift best practices.
The LLM identified 5 files worth highlighting for reuse:
A lightweight dependency injection container that provides access to shell, file system, network, keychain, and logging services. It follows a Point-Free style environment pattern, allowing all external interactions to be mocked for unit testing. This is a clean, reusable pattern for any Swift application that needs to decouple infrastructure from business logic.
A generic thread-safe wrapper using OSAllocatedUnfairLock to synchronize access to mutable state. Provides a simple interface for reading and mutating values atomically. This is a reusable utility class for any Swift concurrency scenario requiring safe shared mutable state, easily extractable as a standalone component.
Implements a strategy pattern for downloading Xcode archives, supporting both URLSession and aria2 backends. Includes retry logic, progress tracking, and the ability to switch strategies at runtime. The separation of concerns makes it easy to add new download methods (e.g., external download managers) without affecting the rest of the codebase.
Encapsulates the full two-factor authentication flow for Apple ID, including SMS code delivery, trusted device approval, and fallback modes. Manages session state and interacts with the keychain for persistent sessions. This component could be extracted and reused in any Swift application that needs to authenticate with Apple Developer services.
A standalone, high-performance LZFSE-based unarchiver for Apple's .xip format, originally created by Saagar Jha. It provides significantly faster expansion than the built-in archive utility by decompressing chunks in parallel. Although vendored, it is a well-isolated component that can be reused in any Swift project needing to extract Apple's compressed XIP files.