Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Leave an excluded app's extensions off the Extensions page
Țugui Dragoș9dcf5ebf02de
diff --git a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swiftindex fcda9b16..7df26b11 100644--- a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift+++ b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift@@ -108,6 +108,14 @@ public struct AppExtension: Sendable, Hashable, Identifiable {}extension AppExtension {+ /// The app the extension came with: the app its bundle is inside, or, for a system extension, the app macOS's+ /// record says it was installed for.+ var app: URL? {+ kind == .systemExtension+ ? installedFor.map { URL(filePath: $0) }+ : url.flatMap { AppExtensions.app(ofExtensionAt: $0.path(percentEncoded: false)) }+ }+/// Where the person turns an extension on and off, which the point it plugs into decides.public enum Switch: Sendable, Hashable {/// System Settings > General > Login Items & Extensions.@@ -220,9 +228,16 @@ public enum AppExtensions {let apps = await appExtensions(run: run)let system = await systemExtensions(run: run)let found = (apps ?? []) + (system ?? [])+ // An extension is its app's, so an app excluded by its identifier leaves its extensions out too.+ var excludedApps: [URL: Bool] = [:]return ExtensionScan(extensions: found.filter { extensionItem inguard !exclusions.excludes(bundleIdentifier: extensionItem.identifier) else { return false }+ if let app = extensionItem.app {+ let isExcluded = excludedApps[app] ?? (exclusions.isAnExcludedApp(app) || exclusions.excludes(app))+ excludedApps[app] = isExcluded+ if isExcluded { return false }+ }return extensionItem.url.map { !exclusions.excludes($0) } ?? true}.sorted {@@ -346,11 +361,16 @@ public enum AppExtensions {/// The name of the app the extension came with. This is the outermost app, so an extension inside/// Instruments inside Xcode belongs to Xcode.static func owner(ofExtensionAt path: String) -> String? {+ app(ofExtensionAt: path).flatMap { AppInspector.displayName(of: $0) }+ }++ /// The app an extension at `path` is part of: the outermost app bundle it is inside, or the app itself.+ static func app(ofExtensionAt path: String) -> URL? {guardlet end = path.range(of: ".app/")?? (path.hasSuffix(".app") ? path.range(of: ".app", options: .backwards) : nil)else { return nil }- return AppInspector.displayName(of: URL(filePath: String(path[..<end.lowerBound]) + ".app"))+ return URL(filePath: String(path[..<end.lowerBound]) + ".app")}/// Nil when macOS gave no answer Peel can read, which is not the same as none installed.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swiftindex 4ec28724..6e5064ca 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift@@ -353,6 +353,28 @@ struct AppExtensionsTests {#expect(AppExtensions.extensionPoint(in: nil) == nil)}+ @Test func leavesOutTheExtensionsOfAnExcludedApp() async throws {+ let directory = try TemporaryDirectory()+ let info = try PropertyListSerialization.data(+ fromPropertyList: ["CFBundleIdentifier": "org.example.chat"], format: .xml, options: 0+ )+ try directory.file("Chat.app/Contents/Info.plist", contents: info)+ let appex = try directory.directory("Chat.app/Contents/PlugIns/Share.appex")+ let listing = """+ org.example.chat.share(1.0)\t6299ACC7-6EDA-4A38-9BD4-89444C604682\t2026-09-20 17:23:02 +0000\t\+ \(appex.path(percentEncoded: false))+ (1 plug-in)+ """+ let run: AppExtensions.Runner = { tool, _ in tool.hasSuffix("/pluginkit") ? listing : "0 extension(s)" }+ let byIdentifier = Exclusions(bundleIdentifiers: ["org.example.chat"])++ let listed = await AppExtensions.scan(exclusions: .none, run: run).extensions+ let excluded = await AppExtensions.scan(exclusions: byIdentifier, run: run).extensions++ #expect(listed.map(\.identifier) == ["org.example.chat.share"])+ #expect(excluded.isEmpty)+ }+/// Each kind comes from its own tool, so a tool that gives no answer leaves out its own kind and nothing/// else, and the scan says which kind is missing: what it lists is then only part of what is installed.@Test func saysWhichKindMacOSGaveNoAnswerAbout() async {