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.

Uninstalling looks in ~/Library/Frameworks

Țugui Dragoșff6eb5a8e0f0
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 40df5d89..eab506b8 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -35608,6 +35608,112 @@
}
}
},
+ "Framework" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Framework"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Framework"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Estructura"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Structure"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Framework"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "フレームワーク"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "프레임워크"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Framework"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Szablon roboczy"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Framework"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Cadru"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Структура"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ramverk"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Framework"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Бібліотека"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "框架"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "架構"
+ }
+ }
+ }
+ },
"Free up space from inside the provider’s app" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/DeclaredIdentifier.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/DeclaredIdentifier.swift
index 228e5584..9651961c 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/DeclaredIdentifier.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/DeclaredIdentifier.swift
@@ -7,6 +7,7 @@ enum DeclaredIdentifier {
static func of(_ url: URL, kind: SearchLocation.Kind) -> String? {
switch kind {
case .plugIns: Plugins.declaredIdentifier(at: url)
+ case .frameworks: framework(at: url)
case .containers: container(at: url)
case .logs: CrashReport.bundleIdentifier(of: url)
default: nil
@@ -15,7 +16,13 @@ enum DeclaredIdentifier {
/// True for an item whose name never says whose it is, so what it declares is read even when the name matches.
static func outranksTheName(of url: URL, kind: SearchLocation.Kind) -> Bool {
- kind == .plugIns || (kind == .logs && CrashReport.isOne(url))
+ kind.isLoadedCode || (kind == .logs && CrashReport.isOne(url))
+ }
+
+ /// The `CFBundleIdentifier` a framework's `Resources/Info.plist` declares.
+ private static func framework(at url: URL) -> String? {
+ let resources = url.appending(path: "Resources", directoryHint: .isDirectory)
+ return AppInspector.infoDictionary(in: resources)?["CFBundleIdentifier"] as? String
}
/// The `MCMMetadataIdentifier` in a container's metadata, read only when the folder's name is not already an
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift
index f3a97afe..5385cf01 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift
@@ -128,6 +128,8 @@ struct LeftoverMatcher: Sendable {
fileName.removingSuffix(".log")
case .plugIns:
withoutPlugInExtension(fileName)
+ case .frameworks:
+ fileName.removingSuffix(".framework")
case .hiddenHomeFiles:
fileName.hasPrefix(".") ? String(fileName.dropFirst()) : fileName
default:
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
index 288d3d07..da0b67f7 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
@@ -24,6 +24,8 @@ public struct SearchLocation: Sendable, Hashable {
case startupItems
/// The folders macOS loads plug-ins from.
case plugIns
+ /// `~/Library/Frameworks`, where an app can install a framework other programs load.
+ case frameworks
/// The two files that are an installer receipt, which is how macOS still counts a package as installed.
case receipts
/// The top of a Library itself, where a vendor keeps a folder of its own beside macOS's.
@@ -72,6 +74,7 @@ extension SearchLocation.Kind {
case .launchDaemons: self = .launchDaemons
case .privilegedHelperTools: self = .privilegedHelperTools
case .startupItems: self = .startupItems
+ case .frameworks: self = .frameworks
case .audioUnits, .audioDrivers, .vst, .vst3, .clap, .midiDrivers, .internetPlugIns, .preferencePanes, .quickLook,
.screenSavers, .spotlight, .services, .inputMethods, .colorPickers, .contextualMenuItems, .mailBundles,
.aax, .mas, .imageUnits, .dictionaries, .automatorActions, .contactsPlugIns:
@@ -79,6 +82,12 @@ extension SearchLocation.Kind {
}
}
+ /// True for code macOS loads, which is named for what it does rather than for who made it, and whose date does
+ /// not move when it is used: a plug-in or a framework.
+ var isLoadedCode: Bool {
+ self == .plugIns || self == .frameworks
+ }
+
/// True when this kind of location looks at an entry with this name. The home folder is split in two: hidden
/// entries, and the rest except the folders every account starts with. At the top of a Library, a folder
/// scanned as a location of its own is never offered whole.
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift
index d3b7ff85..84228fd7 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift
@@ -111,10 +111,10 @@ public struct OrphanConfidence: Sendable, Hashable {
group.total.isComplete ? group.lastModified : nil
}
- /// Whole months since the group's last write, from the items whose date moves when they are used: a plug-in's
- /// does not, so a group of plug-ins alone says nothing this way.
+ /// Whole months since the group's last write, from the items whose date moves when they are used: code macOS
+ /// loads keeps its date, so a group of plug-ins alone says nothing this way.
static func monthsUntouched(_ group: OrphanGroup, now: Date) -> Int? {
- let used = group.items.filter { $0.kind != .plugIns }
+ let used = group.items.filter { !$0.kind.isLoadedCode }
guard group.total.isComplete, let written = used.compactMap(\.modificationDate).max(), written <= now else { return nil }
// Counts Gregorian months, whatever calendar the user has set. In a lunar calendar, the default in Saudi
// Arabia, six months end several days sooner.
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
index 858f284e..149b7c1e 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
@@ -274,9 +274,9 @@ public struct OrphanScanner: Sendable {
return await holdsFilesOfAnInstalledApp(url, kind: kind, ownership: ownership) ? nil : app
}
- /// Whether a plug-in came with an app Peel saw go: its identifier is that app's, extends it, or is its maker's.
- /// An installer can put a plug-in in place with no app at all, and its date does not move when it is used, so
- /// nothing else says it was left behind.
+ /// Whether a plug-in or a framework came with an app Peel saw go: its identifier is that app's, extends it, or
+ /// is its maker's. An installer can put one in place with no app at all, and its date does not move when it is
+ /// used, so nothing else says it was left behind.
static func cameWithAnAppThatLeft(_ identifier: String, goneApps: [String]) -> Bool {
let plugIn = identifier.lowercased()
let maker = Identifier.vendor(of: plugIn)
@@ -325,7 +325,7 @@ public struct OrphanScanner: Sendable {
identifier = namedAfter
}
guard let identifier else { continue }
- guard location.kind != .plugIns || cameWithAnAppThatLeft(identifier, goneApps: goneApps) else { continue }
+ guard !location.kind.isLoadedCode || cameWithAnAppThatLeft(identifier, goneApps: goneApps) else { continue }
// The item's own date changes when something is taken out of it, but not when a file inside is
// rewritten in place, so the newest date inside comes from the walk.
diff --git a/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift b/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift
index 9916adf0..d3756bfb 100644
--- a/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift
@@ -70,7 +70,7 @@ extension Plugin.Category {
case .contactsPlugIns: self = .contactsPlugIns
case .applicationSupport, .applicationScripts, .caches, .containers, .groupContainers, .preferences,
.preferencesByHost, .savedApplicationState, .recentDocuments, .logs, .httpStorages, .webKit, .cookies,
- .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems:
+ .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems, .frameworks:
return nil
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
index ba64ba41..dab4d5cd 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
@@ -89,8 +89,9 @@ public struct AppReset: Sendable {
case .applicationSupport, .containers, .groupContainers, .applicationScripts:
.appData
// A reset leaves these alone. What every account on the Mac shares is not one user's to reset, and a
- // plug-in is code that macOS loads, not a setting.
- case .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems, .plugIns, .receipts, .library,
+ // plug-in or a framework is code that macOS loads, not a setting.
+ case .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems, .plugIns, .frameworks, .receipts,
+ .library,
.sharedFolder, .hiddenHomeFiles, .homeFolder, .commandLineTools, .elsewhere:
nil
}
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift b/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift
index 219e95cd..859789ce 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift
@@ -20,6 +20,7 @@ public enum LibraryFolder: String, CaseIterable, Sendable {
/// Apple's "Creating a Startup Item", Daemons and Services Programming Guide: the folder older software installs
/// its startup items in.
case startupItems = "StartupItems"
+ case frameworks = "Frameworks"
case audioUnits = "Audio/Plug-Ins/Components"
case audioDrivers = "Audio/Plug-Ins/HAL"
case vst = "Audio/Plug-Ins/VST"
@@ -60,7 +61,7 @@ public enum LibraryFolder: String, CaseIterable, Sendable {
public static let user: [LibraryFolder] = [
.applicationSupport, .applicationScripts, .caches, .containers, .groupContainers, .preferences,
.preferencesByHost, .savedApplicationState, .recentDocuments, .logs, .httpStorages, .webKit, .cookies,
- .launchAgents,
+ .launchAgents, .frameworks,
]
/// The folders searched in the Mac's own `/Library`, besides the plug-in folders.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift
index 70339a26..7eda8785 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift
@@ -411,6 +411,12 @@ struct LeftoverMatcherTests {
#expect(match("com.xferrecords.serum.qlgenerator", in: .plugIns, for: serum)?.confidence == .certain)
}
+ @Test func aFrameworkIsMatchedWithoutItsExtension() throws {
+ let serum = app("com.xferrecords.serum", name: "Serum")
+ #expect(match("Serum.framework", in: .frameworks, for: serum)?.reason == .name)
+ #expect(match("com.xferrecords.serum.framework", in: .frameworks, for: serum)?.confidence == .certain)
+ }
+
/// An extension missing from the table stays in the key, and its dot reads as a separator. The plug-in is
/// then only a name prefix match: shown as a guess, never selected as the app's own.
@Test func anUnknownPlugInKindIsNeverTakenForTheAppsOwn() throws {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 3d1ec60e..4c6307a5 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -833,6 +833,43 @@ struct LeftoverScannerTests {
#expect(scan.leftovers.allSatisfy { $0.match.reason == .bundleIdentifierPrefix && $0.match.isRecommended })
}
+ /// A framework in `~/Library/Frameworks` is named for what it is, so the identifier in its bundle says whose it
+ /// is. The app's name alone, backed by no identifier, is only a guess.
+ @Test func findsTheAppsFrameworksByTheIdentifierTheyDeclare() async throws {
+ let directory = try TemporaryDirectory()
+ let tunewell = InstalledApp(
+ url: URL(filePath: "/Applications/Tunewell.app"),
+ bundleIdentifier: "net.example.tunewell",
+ name: "Tunewell"
+ )
+ for (name, identifier) in [
+ ("TunewellKit", "net.example.tunewell.kit"), ("Tunewell", "org.example.other.tunewell"),
+ ("Updates", "org.example.updates"),
+ ] {
+ let framework = "home/Library/Frameworks/\(name).framework"
+ try directory.file("\(framework)/Versions/A/Resources/Info.plist", contents: plist(identifier))
+ try FileManager.default.createSymbolicLink(
+ atPath: directory.url.appending(path: "\(framework)/Versions/Current").path(percentEncoded: false),
+ withDestinationPath: "A"
+ )
+ try FileManager.default.createSymbolicLink(
+ atPath: directory.url.appending(path: "\(framework)/Resources").path(percentEncoded: false),
+ withDestinationPath: "Versions/Current/Resources"
+ )
+ }
+
+ let scanner = LeftoverScanner(environment: environment(in: directory))
+ let scan = await scanner.scan(tunewell, installedApps: [tunewell])
+ let found = Dictionary(uniqueKeysWithValues: scan.leftovers.map { ($0.url.lastPathComponent, $0.match) })
+
+ #expect(Set(found.keys) == ["TunewellKit.framework", "Tunewell.framework"])
+ #expect(found["TunewellKit.framework"]?.reason == .bundleIdentifierPrefix)
+ #expect(found["TunewellKit.framework"]?.isRecommended == true)
+ #expect(found["Tunewell.framework"]?.confidence == .possible)
+ #expect(found["Tunewell.framework"]?.isRecommended == false)
+ #expect(scan.leftovers.allSatisfy { $0.kind == .frameworks })
+ }
+
/// A launchd job is named by whoever wrote it, so a job whose program sits inside the app is the app's,
/// whatever its file is called. That match is certain and outranks a weaker match on the file name.
@Test func findsAJobByTheProgramItRuns() async throws {
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index dc47ebc6..8a785565 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -67,6 +67,7 @@ extension SearchLocation.Kind {
case .privilegedHelperTools: "Helper Tool"
case .startupItems: "Startup Item"
case .plugIns: "Plug-in"
+ case .frameworks: "Framework"
case .receipts: "Installer Receipt"
case .library: "Library Folder"
case .temporaryItems: "Temporary Files"
@@ -96,6 +97,7 @@ extension SearchLocation.Kind {
case .privilegedHelperTools: "lock.shield"
case .startupItems: "power"
case .plugIns: "powerplug"
+ case .frameworks: "books.vertical"
case .receipts: "doc.text.below.ecg"
case .library: "building.columns"
case .sharedFolder: "person.2"