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.

Leave out an extension whose app has left

Țugui Dragoș1f8cb78c6211
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0cf9e9ab..1495d2ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -715,6 +715,7 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
#### Extensions
+- An extension whose app has just left is no longer listed, though macOS goes on naming it for a while.
- Each extension says where it is really turned on and off, an excluded app's extensions are left out, and the page
is read again when shown and when Peel comes forward.
- A system extension whose app is gone says the app is no longer installed.
diff --git a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
index a075ddef..ae97e658 100644
--- a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
@@ -256,7 +256,8 @@ public enum AppExtensions {
}
/// Returns what apps added, or nil when `pluginkit` gave no answer Peel can read. It always lists macOS's own
- /// extensions and ends by counting what it listed, so a listing read short of that is not understood.
+ /// extensions and ends by counting what it listed, so a listing read short of that is not understood. It goes on
+ /// listing an extension for a while after its app has left, so what is no longer there is left out.
static func appExtensions(run: Runner) async -> [AppExtension]? {
guard let output = await run("/usr/bin/pluginkit", ["-m", "-v"]) else { return nil }
let lines = output.split(whereSeparator: \.isNewline)
@@ -265,6 +266,7 @@ public enum AppExtensions {
return rows.compactMap { parsed in
guard !isTheSystemsOwn(parsed.path) else { return nil }
let url = URL(filePath: parsed.path, directoryHint: .isDirectory)
+ guard !url.isMissing else { return nil }
let info = AppInspector.infoDictionary(in: url.appending(path: "Contents", directoryHint: .isDirectory))
return AppExtension(
identifier: parsed.identifier,
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
index e3b05b51..84550221 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
@@ -396,6 +396,23 @@ struct AppExtensionsTests {
#expect(await AppExtensions.scan(exclusions: .none, run: both).unanswered.isEmpty)
}
+ @Test func leavesOutAnExtensionWhoseBundleIsNoLongerThere() async throws {
+ let directory = try TemporaryDirectory()
+ let appex = try directory.directory("Chat.app/Contents/PlugIns/Share.appex")
+ let gone = directory.url.appending(path: "Gone.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))
+ org.example.gone.share(1.0)\t6299ACC7-6EDA-4A38-9BD4-89444C604683\t2026-09-20 17:23:02 +0000\t\
+ \(gone.path(percentEncoded: false))
+ (2 plug-ins)
+ """
+
+ let found = try #require(await AppExtensions.appExtensions { _, _ in listing })
+
+ #expect(found.map(\.identifier) == ["org.example.chat.share"])
+ }
+
private static let pluginkit = """
com.apple.example.Sample(1.0)\t6299ACC7-6EDA-4A38-9BD4-89444C604682\t2026-09-20 17:23:02 +0000\t\
/System/Library/Sample.appex