MacSweep
A smart macOS disk cleaner that safely reclaims storage — especially for developers.
The Challenge
The central engineering challenge was building a file system scanner that is both fast and safe. MacSweep solves this with bounded recursion (capped at 4 levels deep for developer artifact searches), async/await parallelism for concurrent category scans, and a multi-tier safety validator that maintains whitelists of 26+ protected system and home paths before any file is touched. A second hard problem was impact scoring: not all files are equal. The app classifies every file into Low, Medium, or Critical impact tiers so users can make informed decisions rather than blindly selecting everything. Reversibility shaped the entire deletion pipeline. Rather than calling FileManager.removeItem directly, the app defaults to trashing files (FileManager.trashItem), making all cleanup reversible by default.
Architectural Decisions
MVVM with @Published ViewModels and @MainActor isolation
Each major screen has its own ViewModel holding @Published state. All ViewModels are annotated with @MainActor to ensure UI updates happen on the main thread, eliminating a whole class of SwiftUI concurrency bugs.
Singleton Services with async/await concurrency
CleanupService, DeveloperToolsService, and SafetyValidator are all shared singletons. Long-running file system operations are async functions, allowing ViewModels to launch them with async let for parallel execution.
Safety-first two-stage deletion pipeline
Every removal goes through SafetyValidator first (checking against 26+ protected path patterns and running a flock()-based in-use check), then routes to moveToTrash() by default. Permanent deletion is a separate, explicit code path.
Centralized design system via Theme.swift
All colors, typography sizes, spacing values, and corner radii are defined in a single Theme.swift file with static constants. This ensures visual consistency across 17+ view components.
Struct-based immutable models with value semantics
All domain models (ScanCategory, ScannedFile, DiskUsage, CleanupResult) are Swift structs. This gives value semantics throughout the app — no shared-mutable-state bugs to chase.
Category-scoped scanning with impact classification
The app defines 9 scan categories each with its own target paths and expected file patterns. Each file gets an ImpactScore (Low/Medium/Critical) based on its category and type.