Skip to content

Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.

feat: onboarding, search, confirmation dialogs, system app protection

moamen0efec83ee90b
diff --git a/PureMac.xcodeproj/project.pbxproj b/PureMac.xcodeproj/project.pbxproj
index 125f29b..f6fee55 100644
--- a/PureMac.xcodeproj/project.pbxproj
+++ b/PureMac.xcodeproj/project.pbxproj
@@ -24,6 +24,7 @@
9BB5AAA574AFED6C27A3F8E2 /* AppPathFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC0FEE7141871ED5F9E36121 /* AppPathFinder.swift */; };
A89DF967EC9E5E8123B2925A /* SmartScanView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11BA091943263913276F3CCF /* SmartScanView.swift */; };
B52938BBD11842631314543D /* CategoryDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10B0AF194677EAC1D5568785 /* CategoryDetailView.swift */; };
+ BC6C800216343438413349A3 /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D4FD34378988D430A582ED0 /* OnboardingView.swift */; };
CDCDFEBA39A3290101F86AC6 /* MainWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F510F232341EE18F11DC934 /* MainWindow.swift */; };
D50EB059E741011EB2523731 /* ScanError.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF15CB1B8EFCA78EF491824 /* ScanError.swift */; };
D9445C2641A8637B65DA5ACE /* ScanEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A711CDF5285F68775D9B5513 /* ScanEngine.swift */; };
@@ -47,6 +48,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>"; };
3A8D39C3C250F26302EC45AB /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
+ 3D4FD34378988D430A582ED0 /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = "<group>"; };
424F7B28624C271620E13BBC /* EmptyStateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyStateView.swift; sourceTree = "<group>"; };
46660271CFF167AB0FE7371D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
5664D2BDAEAA9AE3A53DB364 /* PureMac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PureMac.entitlements; sourceTree = "<group>"; };
@@ -100,6 +102,7 @@
children = (
10B0AF194677EAC1D5568785 /* CategoryDetailView.swift */,
9F510F232341EE18F11DC934 /* MainWindow.swift */,
+ 3D4FD34378988D430A582ED0 /* OnboardingView.swift */,
11BA091943263913276F3CCF /* SmartScanView.swift */,
DAD2EC78EB98016ADA27D114 /* Apps */,
8AE26715B5748307483A1A5E /* Components */,
@@ -314,6 +317,7 @@
DDDA5879006CB97D5D7BDD87 /* Logger.swift in Sources */,
CDCDFEBA39A3290101F86AC6 /* MainWindow.swift in Sources */,
826A750D2D7EC14C2AE306A3 /* Models.swift in Sources */,
+ BC6C800216343438413349A3 /* OnboardingView.swift in Sources */,
FDA30FE6349CA01C8D859F04 /* OrphanListView.swift in Sources */,
EDEF28CAD23E936FBED1783B /* PureMacApp.swift in Sources */,
D9445C2641A8637B65DA5ACE /* ScanEngine.swift in Sources */,
diff --git a/PureMac/Logic/Scanning/AppInfoFetcher.swift b/PureMac/Logic/Scanning/AppInfoFetcher.swift
index 5ba956d..b838363 100644
--- a/PureMac/Logic/Scanning/AppInfoFetcher.swift
+++ b/PureMac/Logic/Scanning/AppInfoFetcher.swift
@@ -26,6 +26,19 @@ final class AppInfoFetcher {
static let shared = AppInfoFetcher()
private let fileManager = FileManager.default
+ private static let protectedBundleIDs: Set<String> = [
+ "com.apple.Safari", "com.apple.finder", "com.apple.AppStore",
+ "com.apple.systempreferences", "com.apple.Terminal",
+ "com.apple.ActivityMonitor", "com.apple.dt.Xcode",
+ "com.apple.mail", "com.apple.iCal", "com.apple.AddressBook",
+ "com.apple.Preview", "com.apple.TextEdit", "com.apple.calculator",
+ "com.apple.MobileSMS", "com.apple.FaceTime", "com.apple.Music",
+ "com.apple.TV", "com.apple.Podcasts", "com.apple.News",
+ "com.apple.Maps", "com.apple.Photos", "com.apple.Notes",
+ "com.apple.reminders", "com.apple.Stocks", "com.apple.Home",
+ "com.apple.weather", "com.apple.clock", "com.apple.Passwords",
+ ]
+
private init() {}
func fetchInstalledApps() -> [InstalledApp] {
@@ -51,8 +64,12 @@ final class AppInfoFetcher {
// Skip subdirectories inside .app bundles
enumerator.skipDescendants()
+ // Skip system/protected apps
+ if url.path.hasPrefix("/System") { continue }
+
guard let app = loadAppInfo(from: url),
- !seenBundleIDs.contains(app.bundleIdentifier) else { continue }
+ !seenBundleIDs.contains(app.bundleIdentifier),
+ !Self.protectedBundleIDs.contains(app.bundleIdentifier) else { continue }
seenBundleIDs.insert(app.bundleIdentifier)
apps.append(app)
diff --git a/PureMac/PureMacApp.swift b/PureMac/PureMacApp.swift
index f1e9620..36150a0 100644
--- a/PureMac/PureMacApp.swift
+++ b/PureMac/PureMacApp.swift
@@ -13,12 +13,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
struct PureMacApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject private var appState = AppState()
+ @AppStorage("PureMac.OnboardingComplete") private var onboardingComplete = false
var body: some Scene {
WindowGroup {
- MainWindow()
- .environmentObject(appState)
- .frame(minWidth: 900, minHeight: 600)
+ if onboardingComplete {
+ MainWindow()
+ .environmentObject(appState)
+ .frame(minWidth: 900, minHeight: 600)
+ } else {
+ OnboardingView(isComplete: $onboardingComplete)
+ }
}
.windowStyle(.automatic)
.windowToolbarStyle(.unified)
diff --git a/PureMac/Views/CategoryDetailView.swift b/PureMac/Views/CategoryDetailView.swift
index e4dbfd5..c623d87 100644
--- a/PureMac/Views/CategoryDetailView.swift
+++ b/PureMac/Views/CategoryDetailView.swift
@@ -5,6 +5,8 @@ struct CategoryDetailView: View {
let category: CleaningCategory
@State private var sortDescending: Bool = true
+ @State private var searchText = ""
+ @State private var showConfirmation = false
private var result: CategoryResult? {
appState.categoryResults[category]
@@ -22,6 +24,7 @@ struct CategoryDetailView: View {
EmptyStateView("Not Scanned", systemImage: category.icon, description: "Run a scan to analyze this category.")
}
}
+ .searchable(text: $searchText, prompt: "Filter files")
.navigationTitle(category.rawValue)
.toolbar {
ToolbarItemGroup {
@@ -56,7 +59,7 @@ struct CategoryDetailView: View {
let selectedCount = appState.selectedCountInCategory(category)
if selectedSize > 0 {
Button {
- appState.cleanCategory(category)
+ showConfirmation = true
} label: {
Label(
"Clean \(selectedCount) items (\(ByteCountFormatter.string(fromByteCount: selectedSize, countStyle: .file)))",
@@ -67,14 +70,25 @@ struct CategoryDetailView: View {
}
}
}
+ .confirmationDialog("Clean \(ByteCountFormatter.string(fromByteCount: appState.selectedSizeInCategory(category), countStyle: .file))?", isPresented: $showConfirmation, titleVisibility: .visible) {
+ Button("Clean", role: .destructive) {
+ appState.cleanCategory(category)
+ }
+ Button("Cancel", role: .cancel) {}
+ } message: {
+ Text("This will permanently delete the selected files. This cannot be undone.")
+ }
}
// MARK: - File List
private func fileList(_ result: CategoryResult) -> some View {
- List {
+ let items = sortedItems(result.items).filter { item in
+ searchText.isEmpty || item.name.localizedCaseInsensitiveContains(searchText) || item.path.localizedCaseInsensitiveContains(searchText)
+ }
+ return List {
Section {
- ForEach(sortedItems(result.items)) { item in
+ ForEach(items) { item in
FileRowView(item: item)
}
} header: {
diff --git a/PureMac/Views/OnboardingView.swift b/PureMac/Views/OnboardingView.swift
new file mode 100644
index 0000000..9e5f07b
--- /dev/null
+++ b/PureMac/Views/OnboardingView.swift
@@ -0,0 +1,171 @@
+import SwiftUI
+
+struct OnboardingView: View {
+ @Binding var isComplete: Bool
+ @State private var currentPage = 0
+ @State private var hasFullDiskAccess = false
+
+ private let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
+
+ var body: some View {
+ VStack(spacing: 0) {
+ // Page content
+ TabView(selection: $currentPage) {
+ welcomePage.tag(0)
+ fdaPage.tag(1)
+ readyPage.tag(2)
+ }
+ .tabViewStyle(.automatic)
+
+ // Navigation
+ HStack {
+ if currentPage > 0 {
+ Button("Back") { withAnimation { currentPage -= 1 } }
+ }
+
+ Spacer()
+
+ // Page dots
+ HStack(spacing: 8) {
+ ForEach(0..<3, id: \.self) { i in
+ Circle()
+ .fill(i == currentPage ? Color.accentColor : Color.secondary.opacity(0.3))
+ .frame(width: 8, height: 8)
+ }
+ }
+
+ Spacer()
+
+ if currentPage < 2 {
+ Button("Next") { withAnimation { currentPage += 1 } }
+ .buttonStyle(.borderedProminent)
+ } else {
+ Button("Get Started") { isComplete = true }
+ .buttonStyle(.borderedProminent)
+ }
+ }
+ .padding()
+ }
+ .frame(width: 520, height: 400)
+ .onReceive(timer) { _ in
+ if currentPage == 1 {
+ checkFDA()
+ }
+ }
+ }
+
+ // MARK: - Welcome
+
+ private var welcomePage: some View {
+ VStack(spacing: 20) {
+ Spacer()
+ if let icon = NSImage(named: "AppIcon") {
+ Image(nsImage: icon)
+ .resizable()
+ .frame(width: 96, height: 96)
+ }
+ Text("Welcome to PureMac")
+ .font(.largeTitle.bold())
+ Text("Free, open-source macOS app manager and system cleaner.")
+ .foregroundStyle(.secondary)
+ .multilineTextAlignment(.center)
+
+ HStack(spacing: 24) {
+ featureCard(icon: "magnifyingglass", title: "Smart Scan", desc: "Find junk files across your system")
+ featureCard(icon: "trash", title: "App Uninstaller", desc: "Remove apps and all their files")
+ featureCard(icon: "doc.questionmark", title: "Orphan Finder", desc: "Find leftovers from deleted apps")
+ }
+ .padding(.top)
+ Spacer()
+ }
+ .padding()
+ }
+
+ private func featureCard(icon: String, title: String, desc: String) -> some View {
+ VStack(spacing: 8) {
+ Image(systemName: icon)
+ .font(.title2)
+ .foregroundStyle(Color.accentColor)
+ Text(title)
+ .font(.callout.bold())
+ Text(desc)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .multilineTextAlignment(.center)
+ }
+ .frame(width: 130)
+ }
+
+ // MARK: - Full Disk Access
+
+ private var fdaPage: some View {
+ VStack(spacing: 20) {
+ Spacer()
+ Image(systemName: hasFullDiskAccess ? "checkmark.shield.fill" : "lock.shield")
+ .font(.system(size: 48))
+ .foregroundStyle(hasFullDiskAccess ? .green : .orange)
+
+ Text("Full Disk Access")
+ .font(.title2.bold())
+
+ if hasFullDiskAccess {
+ Text("Full Disk Access is granted. You're all set!")
+ .foregroundStyle(.green)
+ } else {
+ Text("PureMac needs Full Disk Access to scan all caches, Trash, and app data.")
+ .foregroundStyle(.secondary)
+ .multilineTextAlignment(.center)
+ .frame(maxWidth: 380)
+
+ GroupBox {
+ VStack(alignment: .leading, spacing: 8) {
+ Label("Open System Settings > Privacy & Security", systemImage: "1.circle")
+ Label("Select Full Disk Access", systemImage: "2.circle")
+ Label("Enable PureMac", systemImage: "3.circle")
+ }
+ .font(.callout)
+ }
+ .frame(maxWidth: 380)
+
+ Button("Open System Settings") {
+ NSWorkspace.shared.open(URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles")!)
+ }
+ .buttonStyle(.borderedProminent)
+ }
+ Spacer()
+ }
+ .padding()
+ }
+
+ // MARK: - Ready
+
+ private var readyPage: some View {
+ VStack(spacing: 20) {
+ Spacer()
+ Image(systemName: "checkmark.circle.fill")
+ .font(.system(size: 64))
+ .foregroundStyle(.green)
+ Text("You're Ready")
+ .font(.title.bold())
+
+ HStack(spacing: 8) {
+ Image(systemName: hasFullDiskAccess ? "checkmark.circle.fill" : "xmark.circle.fill")
+ .foregroundStyle(hasFullDiskAccess ? .green : .red)
+ Text("Full Disk Access: \(hasFullDiskAccess ? "Granted" : "Not Granted")")
+ .foregroundStyle(.secondary)
+ }
+
+ if !hasFullDiskAccess {
+ Text("Some features may be limited without Full Disk Access.")
+ .font(.caption)
+ .foregroundStyle(.orange)
+ }
+ Spacer()
+ }
+ .padding()
+ }
+
+ private func checkFDA() {
+ hasFullDiskAccess = FullDiskAccessManager.shared.hasFullDiskAccess
+ }
+}
diff --git a/PureMac/Views/SmartScanView.swift b/PureMac/Views/SmartScanView.swift
index 843d7e8..ebbdd9f 100644
--- a/PureMac/Views/SmartScanView.swift
+++ b/PureMac/Views/SmartScanView.swift
@@ -2,6 +2,7 @@ import SwiftUI
struct SmartScanView: View {
@EnvironmentObject var appState: AppState
+ @State private var showConfirmation = false
var body: some View {
VStack(spacing: 20) {
@@ -140,7 +141,7 @@ struct SmartScanView: View {
HStack(spacing: 12) {
if appState.totalSelectedSize > 0 {
Button("Clean Selected (\(ByteCountFormatter.string(fromByteCount: appState.totalSelectedSize, countStyle: .file)))") {
- appState.cleanAll()
+ showConfirmation = true
}
.buttonStyle(.borderedProminent)
.controlSize(.large)
@@ -151,6 +152,14 @@ struct SmartScanView: View {
}
.controlSize(.large)
}
+ .confirmationDialog("Clean \(ByteCountFormatter.string(fromByteCount: appState.totalSelectedSize, countStyle: .file))?", isPresented: $showConfirmation, titleVisibility: .visible) {
+ Button("Clean", role: .destructive) {
+ appState.cleanAll()
+ }
+ Button("Cancel", role: .cancel) {}
+ } message: {
+ Text("This will permanently delete the selected files. This cannot be undone.")
+ }
} else {
Image(systemName: "checkmark.circle")
.font(.system(size: 48))