Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Developer lists each system version's symbols and each archive on its own

Țugui Dragoș45059f666b2a
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 937bc16f..0e5476c5 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -129059,6 +129059,112 @@
}
}
},
+ "Version %@, needed to read its crash reports" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Verze %@, potřebná ke čtení jejích zpráv o haváriích"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Version %@, die zum Lesen ihrer Absturzberichte nötig ist"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versión %@, necesaria para leer sus informes de errores"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Version %@, nécessaire pour lire ses rapports de blocage"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versione %@, necessaria per leggerne i resoconti dei blocchi"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "バージョン%@のクラッシュレポートを読むのに必要"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "버전 %@, 해당 버전의 충돌 리포트를 읽는 데 필요함"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versie %@, nodig om de crashrapporten ervan te lezen"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Wersja %@, potrzebna do odczytywania raportów o awariach tej wersji"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versão %@, necessária para ler os relatórios de falha dela"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versiunea %@, necesară pentru a citi rapoartele ei de oprire subită"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Версия %@, которая нужна для чтения ее отчетов о сбоях"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Version %@, behövs för att läsa dess kraschrapporter"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sürüm %@, bu sürümün çökme raporlarını okumak için gerekir"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Версія %@, потрібна для читання її звітів про аварії"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "版本%@,读取该版本的崩溃报告时需要用到"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "版本%@,讀取該版本的當機報告時需要用到"
+ }
+ }
+ }
+ },
"Video wallpapers macOS downloaded." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index f10d6c29..b038823f 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -22,6 +22,20 @@ public struct DeveloperEnvironment: Sendable, Hashable, Identifiable {
case keptDownloads
}
+ /// What an Xcode archive's own `Info.plist` says of the app inside it.
+ public struct Archive: Sendable, Hashable {
+ public let version: String?
+ public let build: String?
+
+ /// The version as Xcode's Organizer writes it, `2.1 (45)`, or whichever of the two the archive names.
+ public var label: String? {
+ switch (version, build) {
+ case let (version?, build?): "\(version) (\(build))"
+ case let (version, build): version ?? build
+ }
+ }
+ }
+
public struct Location: Sendable, Hashable, Identifiable {
public let url: URL
public let kind: ContentKind
@@ -31,6 +45,7 @@ public struct DeveloperEnvironment: Sendable, Hashable, Identifiable {
public let source: String
/// True when macOS would not let Peel open the folder, rather than it not answering in time.
public var couldNotBeRead = false
+ public var archive: Archive?
public var id: URL { url }
@@ -86,12 +101,42 @@ public enum DeveloperCaches {
/// A store the tool can turn on inside the folder, which projects then link into. While an entry by that
/// name is there, a link included, the folder is listed without a checkmark: moving it breaks them.
let storeInside: String?
+ /// How far inside the folder its rows are: 0 lists it whole, 1 lists each folder in it, as Xcode keeps one per
+ /// system version, and 2 each folder two levels down, as Xcode keeps each archive in a folder for its day.
+ /// Listed rather than globbed, since `glob` stops at 128 paths.
+ let rowsDepth: Int
+ /// The ending every row's name has, such as `.xcarchive`, or nil for any.
+ let rowEnding: String?
- init(_ path: String, _ kind: DeveloperEnvironment.ContentKind, source: String, storeInside: String? = nil) {
+ init(
+ _ path: String, _ kind: DeveloperEnvironment.ContentKind, source: String, storeInside: String? = nil,
+ rowsDepth: Int = 0, rowEnding: String? = nil
+ ) {
self.path = path
self.kind = kind
self.source = source
self.storeInside = storeInside
+ self.rowsDepth = rowsDepth
+ self.rowEnding = rowEnding
+ }
+
+ func rows(in folder: URL) -> [URL] {
+ var level = [folder]
+ for _ in 0..<rowsDepth {
+ level = level.flatMap { folder in
+ let keys: [URLResourceKey] = [.isDirectoryKey, .isSymbolicLinkKey]
+ let entries = (try? FileManager.default.contentsOfDirectory(
+ at: folder, includingPropertiesForKeys: keys, options: [.skipsHiddenFiles]
+ )) ?? []
+ // Named from `folder`, which keeps the spelling the rest of the list uses.
+ return entries.filter { entry in
+ let values = try? entry.resourceValues(forKeys: Set(keys))
+ return values?.isDirectory == true && values?.isSymbolicLink != true
+ }.map { folder.appending(path: $0.lastPathComponent, directoryHint: .notDirectory) }
+ }
+ }
+ guard rowsDepth > 0, let rowEnding else { return level }
+ return level.filter { $0.lastPathComponent.hasSuffix(rowEnding) }
}
/// What the folder at `url` holds now: installed packages once its store is there, `kind` otherwise.
@@ -102,6 +147,18 @@ public enum DeveloperCaches {
}
}
+ static func archive(at url: URL) -> DeveloperEnvironment.Archive? {
+ guard
+ let data = try? Data(contentsOf: url.appending(path: "Info.plist")),
+ let facts = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any],
+ let app = facts["ApplicationProperties"] as? [String: Any]
+ else { return nil }
+ let version = app["CFBundleShortVersionString"] as? String
+ let build = app["CFBundleVersion"] as? String
+ guard version != nil || build != nil else { return nil }
+ return DeveloperEnvironment.Archive(version: version, build: build)
+ }
+
/// The tools' own folders inside `folder`, as the name patterns leading to each (`["Google", "AndroidStudio*"]`),
/// which Space leaves to the Developer page. Both folders are read as the kernel names them, so another spelling
/// of the same folder (another case, a link) finds the same.
@@ -130,15 +187,15 @@ public enum DeveloperCaches {
Definition(id: "xcode", name: "Xcode", systemImage: "hammer", appBundleIdentifiers: ["com.apple.dt.Xcode", "com.apple.iphonesimulator"], folders: [
Folder("Library/Developer/Xcode/DerivedData", .buildData, source: "https://developer.apple.com/documentation/xcode-release-notes/xcode-26-release-notes"),
Folder("Library/Developer/Xcode/UserData/Previews/Simulator Devices", .buildData, source: "Xcode 27: DVTSystemPrerequisites.framework, beside DVTSimulatorDeviceRemover"),
- Folder("Library/Developer/Xcode/iOS DeviceSupport", .deviceSupport, source: "https://developer.apple.com/documentation/xcode-release-notes/xcode-12_2-release-notes"),
- Folder("Library/Developer/Xcode/watchOS DeviceSupport", .deviceSupport, source: "Xcode 27: CoreSymbolicationDT.framework/Resources/JSONCrashLog/DeviceSupportDirectories.py"),
- Folder("Library/Developer/Xcode/tvOS DeviceSupport", .deviceSupport, source: "Xcode 27: CoreSymbolicationDT.framework/Resources/JSONCrashLog/DeviceSupportDirectories.py"),
- Folder("Library/Developer/Xcode/visionOS DeviceSupport", .deviceSupport, source: "Xcode 27: DVTFoundation.framework (\"%@ DeviceSupport\") and XROS.platform/Info.plist (Description visionOS)"),
- Folder("Library/Developer/Xcode/macOS DeviceSupport", .deviceSupport, source: "Xcode 27: CoreSymbolicationDT.framework/Resources/JSONCrashLog/DeviceSupportDirectories.py"),
+ Folder("Library/Developer/Xcode/iOS DeviceSupport", .deviceSupport, source: "https://developer.apple.com/documentation/xcode-release-notes/xcode-12_2-release-notes", rowsDepth: 1),
+ Folder("Library/Developer/Xcode/watchOS DeviceSupport", .deviceSupport, source: "Xcode 27: CoreSymbolicationDT.framework/Resources/JSONCrashLog/DeviceSupportDirectories.py", rowsDepth: 1),
+ Folder("Library/Developer/Xcode/tvOS DeviceSupport", .deviceSupport, source: "Xcode 27: CoreSymbolicationDT.framework/Resources/JSONCrashLog/DeviceSupportDirectories.py", rowsDepth: 1),
+ Folder("Library/Developer/Xcode/visionOS DeviceSupport", .deviceSupport, source: "Xcode 27: DVTFoundation.framework (\"%@ DeviceSupport\") and XROS.platform/Info.plist (Description visionOS)", rowsDepth: 1),
+ Folder("Library/Developer/Xcode/macOS DeviceSupport", .deviceSupport, source: "Xcode 27: CoreSymbolicationDT.framework/Resources/JSONCrashLog/DeviceSupportDirectories.py", rowsDepth: 1),
Folder("Library/Developer/CoreSimulator/Caches", .cache, source: "https://developer.apple.com/documentation/xcode-release-notes/xcode-12_3-release-notes"),
Folder("Library/Caches/com.apple.dt.Xcode", .cache, source: "https://developer.apple.com/documentation/foundation/filemanager/searchpathdirectory/cachesdirectory"),
Folder("Library/Developer/Packages", .keptDownloads, source: "https://developer.apple.com/documentation/xcode-release-notes/xcode-16_2-release-notes"),
- Folder("Library/Developer/Xcode/Archives", .archives, source: "Xcode 27: IDEFoundation.framework, -[IDEDeveloperPaths defaultDistributionArchivesLocation]"),
+ Folder("Library/Developer/Xcode/Archives", .archives, source: "Xcode 27: IDEFoundation.framework, -[IDEDeveloperPaths defaultDistributionArchivesLocation]", rowsDepth: 2, rowEnding: ".xcarchive"),
]),
Definition(id: "swiftpm", name: "Swift Package Manager", systemImage: "swift", appBundleIdentifiers: [], folders: [
Folder("Library/Caches/org.swift.swiftpm", .downloads, source: "https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Basics/FileSystem/FileSystem+Extensions.swift#L246-L253"),
@@ -787,7 +844,7 @@ public enum DeveloperCaches {
_ = group.addTaskUnlessCancelled {
var found: [(url: URL, folder: Folder)] = []
for folder in definition.folders {
- for url in PathPattern.expand(folder.path, home: homeDirectory) {
+ for url in PathPattern.expand(folder.path, home: homeDirectory).flatMap(folder.rows) {
guard !exclusions.excludes(url), !exclusions.holds(url) else { continue }
// Skips a folder that holds work kept nowhere else, such as the state Deno's
// scripts keep in `location_data`. Removing it would lose that work.
@@ -814,7 +871,8 @@ public enum DeveloperCaches {
kind: folder.kind(at: url),
size: contents.flatMap { $0.couldNotBeRead ? nil : $0.size },
source: folder.source,
- couldNotBeRead: contents?.couldNotBeRead == true
+ couldNotBeRead: contents?.couldNotBeRead == true,
+ archive: folder.kind == .archives ? Self.archive(at: url) : nil
))
}
guard !locations.isEmpty else { return nil }
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index 8500facb..e523ee76 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -85,7 +85,7 @@ struct DeveloperCachesTests {
try directory.file(".npm/_cacache/content/data", bytes: 80_000)
try directory.file(".npm/_npx/package/index.js", bytes: 8_000)
try directory.file("Library/Developer/Xcode/DerivedData/Build/output", bytes: 20_000)
- try directory.directory("Library/Developer/Xcode/Archives/2026-09-17")
+ try directory.directory("Library/Developer/Xcode/Archives/2026-09-17/App 17.09.2026, 10.00.xcarchive")
let environments = await DeveloperCaches.scan(homeDirectory: directory.url)
@@ -355,14 +355,15 @@ struct DeveloperCachesTests {
let directory = try TemporaryDirectory()
var expected: Set<String> = []
for definition in DeveloperCaches.definitions {
- for path in definition.folders.map(\.path) {
+ for folder in definition.folders {
// A wildcard becomes a name it matches: `*` any folder, `[0-9a-f]` one of ccache's shards. A pattern
// that ends in `/` matches every folder beside, so what sits beside its match is a file.
- let concrete = path.replacingOccurrences(of: "*", with: "match").replacingOccurrences(of: "[0-9a-f]", with: "a")
+ let concrete = folder.path.replacingOccurrences(of: "*", with: "match").replacingOccurrences(of: "[0-9a-f]", with: "a")
let foldersOnly = concrete.hasSuffix("/")
let entry = foldersOnly ? String(concrete.dropLast()) : concrete
- try directory.file("\(entry)/content", bytes: 400_000)
- expected.insert(entry)
+ let row = entry + (0..<folder.rowsDepth).map { "/row \($0)" }.joined() + (folder.rowEnding ?? "")
+ try directory.file("\(row)/content", bytes: 400_000)
+ expected.insert(row)
try directory.file("\(entry)/../elsewhere-\(definition.id)" + (foldersOnly ? "" : "/content"), bytes: 400_000)
}
}
@@ -445,6 +446,52 @@ struct DeveloperCachesTests {
#expect(locations.allSatisfy { $0.kind == .deviceSupport && !$0.isRecommended })
}
+ @Test func listsEachSystemVersionsSymbolsOnItsOwnAndSelectsNone() async throws {
+ let directory = try TemporaryDirectory()
+ let support = "Library/Developer/Xcode/iOS DeviceSupport"
+ try directory.file("\(support)/iPhone17,1 18.6 (22G86)/Symbols/dyld", bytes: 400_000)
+ try directory.file("\(support)/iPhone17,1 26.0 (23A341)/Symbols/dyld", bytes: 400_000)
+ try directory.file("\(support)/.DS_Store", bytes: 16)
+
+ let locations = await DeveloperCaches.scan(homeDirectory: directory.url).flatMap(\.locations)
+
+ #expect(Set(locations.map(\.url.lastPathComponent)) == ["iPhone17,1 18.6 (22G86)", "iPhone17,1 26.0 (23A341)"])
+ #expect(locations.allSatisfy { $0.kind == .deviceSupport && !$0.isRecommended })
+ }
+
+ @Test func listsEachArchiveWithTheVersionItHoldsAndSelectsNone() async throws {
+ let directory = try TemporaryDirectory()
+ let archives = "Library/Developer/Xcode/Archives"
+ let facts: [String: Any] = ["ApplicationProperties": ["CFBundleShortVersionString": "2.1", "CFBundleVersion": "45"]]
+ try directory.file(
+ "\(archives)/2026-09-01/App 01.09.2026, 10.00.xcarchive/Info.plist",
+ contents: try PropertyListSerialization.data(fromPropertyList: facts, format: .xml, options: 0)
+ )
+ try directory.file("\(archives)/2026-09-02/App 02.09.2026, 11.00.xcarchive/Products/Applications/App.app/App", bytes: 400_000)
+ try directory.file("\(archives)/2026-09-02/notes.txt", bytes: 16)
+
+ let locations = await DeveloperCaches.scan(homeDirectory: directory.url).flatMap(\.locations)
+
+ #expect(locations.count == 2)
+ #expect(locations.allSatisfy { $0.kind == .archives && !$0.isRecommended })
+ let first = try #require(locations.first { $0.url.lastPathComponent.hasPrefix("App 01.09") })
+ #expect(first.archive == DeveloperEnvironment.Archive(version: "2.1", build: "45"))
+ #expect(first.archive?.label == "2.1 (45)")
+ #expect(DeveloperEnvironment.Archive(version: nil, build: "45").label == "45")
+ #expect(locations.first { $0.url.lastPathComponent.hasPrefix("App 02.09") }?.archive == nil)
+ }
+
+ @Test func listsEveryArchiveHoweverManyThereAre() async throws {
+ let directory = try TemporaryDirectory()
+ for day in 1...130 {
+ try directory.directory("Library/Developer/Xcode/Archives/day \(day)/App \(day).xcarchive")
+ }
+
+ let locations = await DeveloperCaches.scan(homeDirectory: directory.url).flatMap(\.locations)
+
+ #expect(locations.count == 130)
+ }
+
/// Peel reads cask definitions from Homebrew's `api` folder, which `brew cleanup` leaves alone too. It is
/// never offered: without it, the next Homebrew question would go to the network.
@Test func leavesHomebrewsCopyOfTheCaskDefinitions() async throws {
diff --git a/Peel/Views/Developer/DeveloperDetailView.swift b/Peel/Views/Developer/DeveloperDetailView.swift
index 57cfe095..af5018a0 100644
--- a/Peel/Views/Developer/DeveloperDetailView.swift
+++ b/Peel/Views/Developer/DeveloperDetailView.swift
@@ -16,7 +16,7 @@ struct DeveloperDetailView: View {
RemovalRow(
url: location.url,
icon: .symbol(location.kind.symbolName),
- detail: location.kind.title,
+ detail: detail(for: location),
warning: location.size == nil ? String(localized: location.couldNotBeRead ? HoldBack.couldNotBeRead.explanation : HoldBack.notMeasured.explanation) : nil,
size: location.size ?? 0,
isMeasured: location.size != nil,
@@ -61,6 +61,11 @@ struct DeveloperDetailView: View {
}
}
+ private func detail(for location: DeveloperEnvironment.Location) -> LocalizedStringResource {
+ guard let version = location.archive?.label else { return location.kind.title }
+ return "Version \(version), needed to read its crash reports"
+ }
+
private var keptByDefault: Int {
environment.locations.count { !$0.isRecommended }
}