Skip to content

iliyami/MacClean

Mac Clean Icon

Mac Clean

The open-source Mac cleaner, optimizer, and malware scanner.
A feature-complete, free alternative to CleanMyMac — built with Swift 6 and SwiftUI.

macOS 14+ Swift 6 Tests License Security PRs Welcome

Mac Clean Screenshot

Install in one command:

brew tap iliyami/macclean && brew install --cask mac-clean

Or grab the latest DMG from Releases.


What is Mac Clean?

Mac Clean is a free, open-source macOS app that cleans junk files, removes malware, optimizes performance, uninstalls apps completely, and visualizes disk usage — all from a single, beautiful interface. It replicates every major feature of CleanMyMac while being fully transparent and community-driven.

No subscriptions. No telemetry. No ads. Just a clean Mac.

How Mac Clean compares

Mac Clean CleanMyMac Pearcleaner PureMac OnyX
Price Free $39.95/yr Free Free Free
Open source ✅ BSD-3 ✅ Fair-code ✅ MIT
Telemetry ❌ None ⚠️ Yes ❌ None ❌ None ❌ None
Smart Scan (one-click) ➖ Partial
System Junk (16 categories) ➖ Limited
Malware scanner
Browser privacy cleaner
Uninstaller with leftover detection ✅ 10-level ✅ Focus
Disk treemap visualizer
Duplicate finder
Menu bar system monitor ✅ Menu
Maintenance scripts ✅ Strong
Notarized by Apple
macOS version 14+ 13+ 13+ 13+ varies

CleanMyMac is a great product — they deserve the revenue from users who want a polished, supported experience. Mac Clean is for everyone who'd rather have transparent source code and zero subscription.

Features

Cleanup

Module Description
Smart Scan One-click scan combining cleanup, protection, and performance analysis with live progress across 13 modules
System Junk 16 scan categories — user/system caches, logs, language files, broken preferences, broken login items, document versions, iOS backups, Xcode junk, universal binaries, deleted users, and more
Mail Attachments Find cached attachments from Apple Mail, Outlook, and Spark
Trash Bins Empty trash from all locations including external drives

Protection

Module Description
Malware Removal Signature-based scanning with 3 depths (Quick / Balanced / Deep), checks launch agents/daemons, browser extensions, and known malware patterns
Privacy Clean Safari, Chrome, and Firefox data — history, cookies, cache. System traces cleanup with time filters

Performance

Module Description
Optimization Manage login items and launch agents with enable/disable toggles
Maintenance 10 system tasks — free RAM, run maintenance scripts, repair permissions, rebuild Launch Services, reindex Spotlight, flush DNS, thin Time Machine snapshots

Applications

Module Description
Uninstaller 10-level app matching engine that finds every associated file across 17+ Library subdirectories. Complete removal, app reset, unused app detection
Updater Check for available updates across installed apps via Sparkle appcast feeds

Files

Module Description
Space Lens Squarified treemap visualization of disk usage with drill-down navigation
Large & Old Files Find files >50 MB sorted by size and last access date
Duplicates Progressive detection — size grouping → partial SHA-256 (4KB) → full hash → inode verification
Shredder Secure file erasure with standard, permanent, and secure overwrite modes

Menu Bar Monitor

Independent menu bar app with real-time system stats:

  • CPU load via host_processor_info (Mach API)
  • Memory pressure via vm_statistics64
  • Disk usage and health
  • Battery charge, health, cycle count, temperature
  • Network throughput via getifaddrs

Architecture

Mac Clean
├── MacClean          — Main SwiftUI app (14 modules, 15 views)
├── MacCleanKit       — Shared framework (models, constants, protocols)
├── MacCleanHelper    — XPC privileged helper (LaunchDaemon for root ops)
├── MacCleanMenu      — Menu bar monitor (independent process)
└── MacCleanTestRunner — Standalone test suite (56 tests)

Tech Stack

Layer Technology
Language Swift 6 with strict concurrency
UI SwiftUI + AppKit hybrid
Concurrency Actors, TaskGroup, async/await, @Sendable
Database GRDB.swift (SQLite) with WAL mode
File Scanning URLResourceKey prefetching on APFS
Incremental Updates FSEvents with historical replay
Privileged Ops SMAppService + NSXPCConnection
System Stats Mach APIs (host_processor_info, vm_statistics64, proc_pidinfo)

Safety Model

Mac Clean is designed to never cause data loss:

  • Protected paths blocklist/System, /usr, /bin, /sbin, Apple system apps are untouchable
  • Trash-first deletion — all removals go to Trash by default
  • Dry-run mode — preview what would be deleted without touching anything
  • TOCTOU prevention — symlinks re-resolved immediately before deletion
  • 10,000 file cap — prevents runaway deletion operations
  • Orphan safety policy — orphan cleanup restricted to caches/logs only
  • Operation logging — every action logged to ~/Library/Logs/MacClean/

Installation

Homebrew (recommended — one command, no warnings)

brew tap iliyami/macclean
brew install --cask mac-clean

The Cask automatically handles Gatekeeper for you. Launch from Spotlight or Applications — no warnings, no right-clicks, no commands.

One-line installer

curl -fsSL https://raw.githubusercontent.com/iliyami/MacClean/main/scripts/install.sh | bash

This downloads the latest DMG, installs the app to /Applications, and removes the quarantine flag automatically.

DMG download

Download the latest DMG from Releases and drag Mac Clean to your Applications folder. On first launch, either right-click the app and choose Open, or run once:

sudo xattr -dr com.apple.quarantine "/Applications/Mac Clean.app"

Build from source

git clone https://github.com/iliyami/MacClean.git
cd MacClean
swift build
swift run MacCleanTestRunner   # run 56 tests
bash scripts/build-dmg.sh      # build local DMG

Granting Full Disk Access

Some modules (Mail Attachments, Privacy, Malware) need Full Disk Access to scan protected areas:

  1. Open System Settings → Privacy & Security → Full Disk Access
  2. Click + and add Mac Clean.app from Applications
  3. Restart Mac Clean

Why Mac Clean isn't notarized by Apple

Apple charges $99/year for a Developer ID — the only way to bypass Gatekeeper warnings on macOS. Mac Clean is free, open-source, and built by volunteers. Paying Apple's annual gatekeeping tax just so users can open the app without a warning isn't worth it when:

  1. The source is right here for you to read
  2. Homebrew install handles it automatically — brew install --cask mac-clean and you're done
  3. The one-line installer handles it automatically
  4. The whole "Gatekeeper warning" thing is just an extra xattr command for direct DMG installs

If our community ever wants to fund a Developer ID (or some other open-source organization wants to sponsor one), we'll happily ship notarized builds. Until then, no paywall just to launch a free app.

For maintainers with a Developer ID who want to ship notarized builds:

export APPLE_DEVELOPER_ID='Developer ID Application: Your Name (TEAMID)'
xcrun notarytool store-credentials 'MacClean' --apple-id YOU@example.com --team-id TEAMID
export NOTARY_PROFILE='MacClean'
bash scripts/build-dmg.sh --notarize

Requirements

  • macOS 14 (Sonoma) or later
  • For building from source: Swift 6 toolchain (Xcode 16+)

Project Structure

Sources/
├── MacClean/
│   ├── App/                    # App entry point, state, content view
│   ├── Core/
│   │   ├── Scanner/            # FileTreeScanner, TargetedScanner, ScanCoordinator
│   │   ├── Cleaner/            # CleaningEngine, SafetyGuard
│   │   ├── Cache/              # GRDB database layer
│   │   └── FSMonitor/          # FSEvents incremental watcher
│   ├── Modules/                # 13 scan modules
│   │   ├── SystemJunk/         # 16 junk categories
│   │   ├── Malware/            # Signature scanner + real-time monitor
│   │   ├── Uninstaller/        # 10-level app matching engine
│   │   ├── SpaceLens/          # Squarified treemap algorithm
│   │   ├── Duplicates/         # Progressive hash pipeline
│   │   └── ...
│   ├── Views/                  # SwiftUI views (14 module views + shared components)
│   ├── ViewModels/             # @Observable view models
│   ├── Services/               # PermissionManager, XPCClient
│   └── Utilities/              # SuperEllipse shape, extensions
├── MacCleanKit/                # Shared models, constants, protocols
├── MacCleanHelper/             # XPC privileged helper (root operations)
├── MacCleanMenu/               # Menu bar system monitor
└── MacCleanTestRunner/         # 56 standalone tests

Tests

swift test

XCTest-based suite covering:

  • SafetyGuard — 24 adversarial tests (symlinks, traversal, NULL bytes, SIP, protected apps, file caps, idempotence)
  • CleaningEngine — 9 integration tests (dry-run, trash, permanent, error handling, operation log)
  • PlistJunkFilter — 9 tests including Apple-system-domain safety contract
  • ScanCoordinator state machine — scan/cancel/category-filter/include-heavy
  • TargetedScanner integration — runs against synthetic temp directory fixtures
  • All 16 system junk categories — pure target declarations + the filter logic on the procedural ones (BrokenPreferences, BrokenLoginItems, UniversalBinaries, DeletedUsers)
  • SquarifiedTreemap — empty, single, multi-node, area conservation, aspect-ratio properties
  • AppMatching — all 10 levels of the uninstaller pattern engine
  • DuplicateDetection — size groups, partial/full hash groups, inode dedup
  • MalwareSignatures — name patterns + suspicious launch agent payloads
  • MaintenanceTask — all 10 tasks have descriptions, icons, executable paths
  • FileGroup — by-size / by-type / by-age grouping
  • AppcastParser — Sparkle XML parsing
  • VolumeInfo — usage math, equality
  • AppDatabase — GRDB cache CRUD, migrations, invalidation
  • FSEventMonitor — invalidated-path computation
  • AppDiscovery, AppPathFinder — smoke tests
  • End-to-end — synthetic fixture → scan → results → clean cycle

Test infrastructure (Tests/MacCleanTestSupport/) provides withTempHome, withFakeApp, withFakePlist, and other fixture helpers so tests stay deterministic and never touch the user's real home.

Coverage target: 85%+ overall, 100% on SafetyGuard and CleaningEngine (the death-and-life files). See docs/TESTING.md for the full roadmap.

Security

Mac Clean takes security seriously:

  • No network access — the app never phones home, no telemetry, no analytics
  • No elevated privileges by default — XPC helper only activated for maintenance tasks
  • Code signature verification — XPC helper validates caller identity
  • Protected paths — 27+ Apple system apps and all SIP-protected paths are blocklisted
  • Open source — every line of code is auditable

Security Audit Checklist

  • No command injection vectors (all Process args are hardcoded constants)
  • No arbitrary file deletion (SafetyGuard validates every path)
  • TOCTOU race condition prevention (symlink re-resolution before delete)
  • File operation caps (10,000 file limit per operation)
  • XPC caller validation (code signature check)
  • No secrets or credentials in source
  • Trash-first policy (recoverable by default)
  • Operation audit log (every action recorded)

Contributing

We welcome contributions! Please read our Contributing Guidelines before submitting a PR.

Quick Start

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (swift run MacCleanTestRunner)
  5. Commit (git commit -m 'Add amazing feature')
  6. Push (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

This project is licensed under the BSD 3-Clause License — see the LICENSE file for details.

This means you can use, modify, and redistribute this code, but you must:

  • Include the original copyright notice
  • Include the license text
  • Not use the name "Mac Clean" or contributors' names to endorse derived products without permission

Acknowledgments

Inspired by the open-source Mac utility community:

  • Pearcleaner — app uninstaller patterns
  • Mole — cleanup categories
  • Tencent Lemon Cleaner — modular architecture
  • Squarified Treemap algorithm by Bruls, Huizing & van Wijk (2000)

Mac Clean is free software built by the community, for the community.
If you find it useful, please star the repo and share it with others.