From 86c0315eebbbd61b1be2bffb74f28efba074b951 Mon Sep 17 00:00:00 2001 From: Matt Kiazyk Date: Tue, 10 Nov 2026 13:22:34 -0500 Subject: [PATCH] Support AEA archives in Xcodes.app --- README.md | 2 + Xcodes.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 +- XcodesTests/AppStateTests.swift | 119 ++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f91e38ae..87e11b7b 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ XcodesApp is now part of the `XcodesOrg` - [read more here](nextstep.md) - Support installing Apple Silicon variants - Review and clean developer storage in a separate Clean Up window. +Xcodes can install Apple’s `.aea` archives on macOS versions with `archiveutil extractXcodeAEA`. If Xcode Releases has an outdated download link, try the Apple Developer data source in Settings. + ## Clean Up Clean Up helps you review developer files, caches, and simulator storage. Open it from the bottom-left **Clean Up** button or the app menu. Nothing is selected or deleted automatically. diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index 0d2af9ca..23e397d9 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -1627,7 +1627,7 @@ repositoryURL = "https://github.com/XcodesOrg/XcodesKit"; requirement = { kind = upToNextMinorVersion; - minimumVersion = 1.1.0; + minimumVersion = 1.2.0; }; }; E89CBD3B2D5FC0B10037ED95 /* XCRemoteSwiftPackageReference "XcodesLoginKit" */ = { diff --git a/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 95498da5..e90b7aa7 100644 --- a/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Xcodes.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -123,8 +123,8 @@ "repositoryURL": "https://github.com/XcodesOrg/XcodesKit", "state": { "branch": null, - "revision": "4d3c6093980978b74c3fa42fc1b90cd1c34ac911", - "version": "1.1.0" + "revision": "37617957ae33310455bfe7cf0835d69e0a6aa3c5", + "version": "1.2.0" } }, { diff --git a/XcodesTests/AppStateTests.swift b/XcodesTests/AppStateTests.swift index b2224cc7..325ebabc 100644 --- a/XcodesTests/AppStateTests.swift +++ b/XcodesTests/AppStateTests.swift @@ -1177,6 +1177,125 @@ class AppStateTests: XCTestCase { ) } + func test_Install_CachedAEAWithExperimentalUnxipEnabled() async throws { + guard let fixturePath = ProcessInfo.processInfo.environment["XCODES_AEA_FIXTURE"] else { + throw XCTSkip("Set XCODES_AEA_FIXTURE to an Apple Xcode AEA archive to run this smoke test.") + } + let fixture = URL(fileURLWithPath: fixturePath) + let root = FileManager.default.temporaryDirectory.appendingPathComponent("Xcodes-AEA-test-\(UUID())", isDirectory: true) + let cache = root.appendingPathComponent("Archive Cache", isDirectory: true) + let destination = root.appendingPathComponent("Install Destination", isDirectory: true) + defer { try? FileManager.default.removeItem(at: root) } + try FileManager.default.createDirectory(at: cache, withIntermediateDirectories: true) + try FileManager.default.createDirectory(at: destination, withIntermediateDirectories: false) + + let version = try XCTUnwrap(Version(xcodeVersion: "27.3 beta")) + let archive = cache.appendingPathComponent("Xcode-\(version).aea") + try FileManager.default.copyItem(at: fixture, to: archive) + let xcode = AvailableXcode( + version: version, + url: URL(string: "https://developer.apple.com/Xcode_27.3_beta.aea")!, + filename: fixture.lastPathComponent, + releaseDate: nil + ) + + Current.defaults.string = { key in + switch key { + case "localPath": cache.path + case "installPath": destination.path + default: nil + } + } + Current.files = Files(trashItem: { url in + try FileManager.default.removeItem(at: url) + return url + }) + Current.network.downloadTaskAsync = { _, _, _ in + XCTFail("The app should reuse the cached AEA") + return (Progress(), Task { throw URLError(.resourceUnavailable) }) + } + Current.shell.unxip = { _ in throw XcodesKitError("AEA must bypass xip") } + Current.shell.unxipExperiment = { _ in throw XcodesKitError("AEA must bypass experimental unxip") } + Current.shell.spctlAssess = XcodesShell().spctlAssess + Current.shell.codesignVerify = XcodesShell().codesignVerify + subject.unxipExperiment = true + subject.helperInstallState = .installed + + let installed = try await subject.installAsync(.version(xcode), downloader: .urlSession, attemptNumber: 0) + let expected = destination.appendingPathComponent("Xcode-\(version.descriptionWithoutBuildMetadata).app") + XCTAssertEqual(installed.path.string, expected.path) + XCTAssertTrue(FileManager.default.fileExists(atPath: expected.path)) + XCTAssertFalse(FileManager.default.fileExists(atPath: archive.path)) + XCTAssertTrue(FileManager.default.fileExists(atPath: fixture.path)) + } + + func test_Install_DownloadedAEAUsingURLSession() async throws { + try await installFromArchiveSmokeServer(format: "aea", downloader: .urlSession) + } + + func test_Install_DownloadedXIPUsingAria2() async throws { + try await installFromArchiveSmokeServer(format: "xip", downloader: .aria2) + } + + private func installFromArchiveSmokeServer(format: String, downloader: Downloader) async throws { + let environment = ProcessInfo.processInfo.environment + guard let server = environment["XCODES_ARCHIVE_SMOKE_URL"].flatMap(URL.init(string:)), + server.scheme == "http", server.host == "127.0.0.1" else { + throw XCTSkip("Set XCODES_ARCHIVE_SMOKE_URL to the loopback fixture server for this smoke test.") + } + let root = FileManager.default.temporaryDirectory.appendingPathComponent("Xcodes-Download-test-\(UUID())", isDirectory: true) + let cache = root.appendingPathComponent("Archive Cache", isDirectory: true) + let destination = root.appendingPathComponent("Install Destination", isDirectory: true) + defer { try? FileManager.default.removeItem(at: root) } + try FileManager.default.createDirectory(at: cache, withIntermediateDirectories: true) + try FileManager.default.createDirectory(at: destination, withIntermediateDirectories: false) + + let version = try XCTUnwrap(Version(xcodeVersion: "27.3 beta")) + let filename = "Xcode_27.3_beta.\(format)" + let url = server.appendingPathComponent("app/\(filename)") + let archive = cache.appendingPathComponent("Xcode-\(version).\(url.pathExtension)") + let xcode = AvailableXcode(version: version, url: url, filename: filename, releaseDate: nil) + XCTAssertFalse(FileManager.default.fileExists(atPath: archive.path)) + + Current.defaults.string = { key in + switch key { + case "localPath": cache.path + case "installPath": destination.path + default: nil + } + } + Current.files = Files(trashItem: { url in + XCTAssertEqual(url.path, archive.path) + try FileManager.default.removeItem(at: url) + return url + }) + Current.network = Network(session: URLSession(configuration: .ephemeral), validateSessionAsync: { .unauthenticated }) + if url.pathExtension == "aea" { + Current.shell.unxip = { _ in throw XcodesKitError("AEA must bypass xip") } + Current.shell.unxipExperiment = { _ in throw XcodesKitError("AEA must bypass experimental unxip") } + } else { + Current.shell.unxip = XcodesShell().unxip + } + Current.shell.spctlAssess = XcodesShell().spctlAssess + Current.shell.codesignVerify = XcodesShell().codesignVerify + subject.unxipExperiment = url.pathExtension == "aea" + subject.helperInstallState = .installed + + let expectedApp = destination.appendingPathComponent("Xcode-\(version.descriptionWithoutBuildMetadata).app") + let expectDamagedXIP = url.pathExtension == "xip" && environment["XCODES_ARCHIVE_SMOKE_EXPECT_DAMAGED_XIP"] == "1" + do { + let installed = try await subject.installAsync(.version(xcode), downloader: downloader, attemptNumber: 0) + XCTAssertFalse(expectDamagedXIP, "Expected the damaged XIP to be rejected") + XCTAssertEqual(installed.path.string, expectedApp.path) + XCTAssertEqual(installed.version.buildMetadataIdentifiers, ["27C5020n"]) + XCTAssertFalse(FileManager.default.fileExists(atPath: archive.path)) + } catch let error as InstallationError { + guard expectDamagedXIP, case let .damagedXIP(rejectedArchive) = error else { throw error } + XCTAssertEqual(rejectedArchive.path, archive.path) + XCTAssertFalse(FileManager.default.fileExists(atPath: expectedApp.path)) + } + } + func test_Install_NotEnoughFreeSpace() async throws { Current.shell.unxip = { _ in throw ProcessExecutionError(