Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.
Swift cache-cleanercleanmymaccleanupdisk-cleanerdisk-spacehomebrewmac-utilitymacosmacos-appmacos-cleanermacosxnativeossosxprivacyswiftswiftuisystem-cleanerxcode-cleaner
fix: disable App Sandbox and add Full Disk Access detection
moamen28ceeebda8c8
diff --git a/PureMac.xcodeproj/project.pbxproj b/PureMac.xcodeproj/project.pbxprojindex 967be2b..a3b90c0 100644--- a/PureMac.xcodeproj/project.pbxproj+++ b/PureMac.xcodeproj/project.pbxproj@@ -20,6 +20,7 @@D9445C2641A8637B65DA5ACE /* ScanEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A711CDF5285F68775D9B5513 /* ScanEngine.swift */; };DDD6BA35DBF32E7A6B5F6F8B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2EA41E1096FA8E3B916AD13 /* Assets.xcassets */; };EDEF28CAD23E936FBED1783B /* PureMacApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63581B70F9B10231964E3602 /* PureMacApp.swift */; };+ F1A2B3C4D5E6F70819203142 /* FullDiskAccessManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D4E5F607182930A1B2 /* FullDiskAccessManager.swift */; };/* End PBXBuildFile section *//* Begin PBXFileReference section */@@ -31,6 +32,7 @@311078221878708524283765 /* PureMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PureMac.app; sourceTree = BUILT_PRODUCTS_DIR; };3667D46D8E2004EB4D73835A /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };46660271CFF167AB0FE7371D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };+ A1B2C3D4E5F607182930A1B2 /* FullDiskAccessManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullDiskAccessManager.swift; sourceTree = "<group>"; };5402892366B3F00417FD05F9 /* SidebarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarView.swift; sourceTree = "<group>"; };5664D2BDAEAA9AE3A53DB364 /* PureMac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PureMac.entitlements; sourceTree = "<group>"; };63581B70F9B10231964E3602 /* PureMacApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PureMacApp.swift; sourceTree = "<group>"; };@@ -82,6 +84,7 @@isa = PBXGroup;children = (2A8DE5D45BA19E2670B57DC5 /* CleaningEngine.swift */,+ A1B2C3D4E5F607182930A1B2 /* FullDiskAccessManager.swift */,A711CDF5285F68775D9B5513 /* ScanEngine.swift */,28181F034530331A550C6A3D /* SchedulerService.swift */,);@@ -196,6 +199,7 @@48D1431A7C99C19EEBDB056B /* CleaningEngine.swift in Sources */,A221744A723582A6D075A7A0 /* ContentView.swift in Sources */,826A750D2D7EC14C2AE306A3 /* Models.swift in Sources */,+ F1A2B3C4D5E6F70819203142 /* FullDiskAccessManager.swift in Sources */,EDEF28CAD23E936FBED1783B /* PureMacApp.swift in Sources */,D9445C2641A8637B65DA5ACE /* ScanEngine.swift in Sources */,27F449EDD1B082FE11FEC9DF /* SchedulerService.swift in Sources */,diff --git a/PureMac/PureMac.entitlements b/PureMac/PureMac.entitlementsindex 52e910c..e89b7f3 100644--- a/PureMac/PureMac.entitlements+++ b/PureMac/PureMac.entitlements@@ -3,26 +3,6 @@<plist version="1.0"><dict><key>com.apple.security.app-sandbox</key>- <true/>- <key>com.apple.security.files.user-selected.read-write</key>- <true/>- <key>com.apple.security.files.downloads.read-write</key>- <true/>- <key>com.apple.security.temporary-exception.files.home-relative-path.read-write</key>- <array>- <string>/Library/Caches/</string>- <string>/Library/Logs/</string>- <string>/Library/Mail Downloads/</string>- <string>/Library/Developer/</string>- <string>/.Trash/</string>- </array>- <key>com.apple.security.temporary-exception.files.absolute-path.read-write</key>- <array>- <string>/tmp/</string>- <string>/private/var/tmp/</string>- <string>/Library/Caches/</string>- <string>/Library/Logs/</string>- <string>/private/var/log/</string>- </array>+ <false/></dict></plist>diff --git a/PureMac/Services/FullDiskAccessManager.swift b/PureMac/Services/FullDiskAccessManager.swiftnew file mode 100644index 0000000..82f4ac4--- /dev/null+++ b/PureMac/Services/FullDiskAccessManager.swift@@ -0,0 +1,68 @@+import AppKit+import Foundation++/// Detects whether Full Disk Access (FDA) has been granted to PureMac.+/// Without FDA, macOS TCC blocks access to ~/Desktop, ~/Documents, ~/Mail,+/// ~/.Trash, and other app containers even for non-sandboxed apps.+final class FullDiskAccessManager {+ static let shared = FullDiskAccessManager()++ private init() {}++ /// Check if Full Disk Access is granted by probing TCC-protected paths.+ /// Returns true if at least one protected path is readable.+ var hasFullDiskAccess: Bool {+ // These paths are protected by TCC and require FDA to read.+ // We try multiple because some may not exist on every system.+ let protectedPaths = [+ FileManager.default.homeDirectoryForCurrentUser+ .appendingPathComponent("Library/Mail").path,+ FileManager.default.homeDirectoryForCurrentUser+ .appendingPathComponent("Library/Safari/Bookmarks.plist").path,+ "/Library/Application Support/com.apple.TCC/TCC.db",+ ]++ for path in protectedPaths {+ if FileManager.default.isReadableFile(atPath: path) {+ return true+ }+ }++ // If none of the protected paths exist, assume FDA is not granted+ // but don't block the user - some paths may legitimately not exist+ // on a fresh system. Check if we can at least list a protected directory.+ let home = FileManager.default.homeDirectoryForCurrentUser.path+ let trashPath = "\(home)/.Trash"+ if let contents = try? FileManager.default.contentsOfDirectory(atPath: trashPath),+ !contents.isEmpty {+ return true+ }++ // Try listing Desktop - if TCC blocks it, we get an empty array or error+ let desktopPath = "\(home)/Desktop"+ do {+ let contents = try FileManager.default.contentsOfDirectory(atPath: desktopPath)+ // If Desktop exists and has files, FDA is likely granted+ // (An empty Desktop is ambiguous, so we check more paths)+ if !contents.isEmpty { return true }+ } catch {+ // Permission denied = no FDA+ return false+ }++ // Ambiguous - Desktop is empty, try one more path+ let mailDir = "\(home)/Library/Mail"+ if FileManager.default.fileExists(atPath: mailDir) {+ return FileManager.default.isReadableFile(atPath: mailDir)+ }++ // Can't determine definitively - default to warning the user+ return false+ }++ /// Opens System Settings to the Full Disk Access pane.+ func openFullDiskAccessSettings() {+ let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles")!+ NSWorkspace.shared.open(url)+ }+}diff --git a/PureMac/Services/ScanEngine.swift b/PureMac/Services/ScanEngine.swiftindex 5b939f6..53e9047 100644--- a/PureMac/Services/ScanEngine.swift+++ b/PureMac/Services/ScanEngine.swift@@ -268,10 +268,13 @@ actor ScanEngine {private func scanBrewCache() async -> CategoryResult {var items: [CleanableItem] = []- // Homebrew cache location+ // Homebrew cache locations (Apple Silicon + Intel)let brewCachePaths = ["\(home)/Library/Caches/Homebrew","/opt/homebrew/Caskroom/.metadata",+ "/usr/local/Caskroom/.metadata",+ "/opt/homebrew/Cellar/.metadata",+ "/usr/local/Cellar/.metadata",]for path in brewCachePaths {diff --git a/PureMac/ViewModels/AppViewModel.swift b/PureMac/ViewModels/AppViewModel.swiftindex b776022..485b048 100644--- a/PureMac/ViewModels/AppViewModel.swift+++ b/PureMac/ViewModels/AppViewModel.swift@@ -16,6 +16,8 @@ class AppViewModel: ObservableObject {@Published var showCleanConfirmation = false@Published var lastCleanedDate: Date?@Published var deselectedItems: Set<UUID> = []+ @Published var hasFullDiskAccess: Bool = true+ @Published var fdaBannerDismissed: Bool = falsevar scheduler = SchedulerService()private let scanEngine = ScanEngine()@@ -81,12 +83,28 @@ class AppViewModel: ObservableObject {init() {loadDiskInfo()+ checkFullDiskAccess()scheduler.setTrigger { [weak self] inawait self?.runScheduledScan()}scheduler.start()}+ // MARK: - Full Disk Access++ func checkFullDiskAccess() {+ Task.detached {+ let granted = FullDiskAccessManager.shared.hasFullDiskAccess+ await MainActor.run { [weak self] in+ self?.hasFullDiskAccess = granted+ }+ }+ }++ func openFullDiskAccessSettings() {+ FullDiskAccessManager.shared.openFullDiskAccessSettings()+ }+// MARK: - Disk Infofunc loadDiskInfo() {diff --git a/PureMac/Views/ContentView.swift b/PureMac/Views/ContentView.swiftindex a728c90..becb6c9 100644--- a/PureMac/Views/ContentView.swift+++ b/PureMac/Views/ContentView.swift@@ -17,6 +17,14 @@ struct ContentView: View {.ignoresSafeArea()VStack(spacing: 0) {+ // Full Disk Access banner+ if !vm.hasFullDiskAccess && !vm.fdaBannerDismissed {+ FullDiskAccessBanner()+ .padding(.horizontal, 24)+ .padding(.top, 12)+ .transition(.move(edge: .top).combined(with: .opacity))+ }+// Top bar with disk infoTopBarView().padding(.horizontal, 24)@@ -40,6 +48,69 @@ struct ContentView: View {.onAppear {NSWindow.allowsAutomaticWindowTabbing = false}+ .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in+ vm.checkFullDiskAccess()+ }+ }+}++// MARK: - Full Disk Access Banner++struct FullDiskAccessBanner: View {+ @EnvironmentObject var vm: AppViewModel++ var body: some View {+ HStack(spacing: 12) {+ Image(systemName: "lock.shield.fill")+ .font(.system(size: 18))+ .foregroundColor(.pmWarning)++ VStack(alignment: .leading, spacing: 2) {+ Text("Full Disk Access Required")+ .font(.system(size: 13, weight: .semibold, design: .rounded))+ .foregroundColor(.pmTextPrimary)++ Text("PureMac needs Full Disk Access to scan Trash, Mail, Desktop, Documents, and Homebrew cache.")+ .font(.system(size: 11))+ .foregroundColor(.pmTextSecondary)+ .lineLimit(2)+ }++ Spacer()++ Button(action: { vm.openFullDiskAccessSettings() }) {+ Text("Open Settings")+ .font(.system(size: 12, weight: .semibold, design: .rounded))+ .foregroundColor(.white)+ .padding(.horizontal, 14)+ .padding(.vertical, 6)+ .background(AppGradients.accent)+ .cornerRadius(8)+ }+ .buttonStyle(.plain)++ Button(action: {+ withAnimation(.pmSmooth) {+ vm.fdaBannerDismissed = true+ }+ }) {+ Image(systemName: "xmark")+ .font(.system(size: 10, weight: .bold))+ .foregroundColor(.pmTextMuted)+ .frame(width: 20, height: 20)+ }+ .buttonStyle(.plain)+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 12)+ .background(+ RoundedRectangle(cornerRadius: 12)+ .fill(Color.pmWarning.opacity(0.08))+ .overlay(+ RoundedRectangle(cornerRadius: 12)+ .stroke(Color.pmWarning.opacity(0.2), lineWidth: 1)+ )+ )}}