Skip to content

AlexTkDev/MacOSCleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

macOS Cleaner

macOS Cleaner

License: Custom Non-Commercial Platform: macOS Language: Swift 6 UI: SwiftUI Build: XcodeGen Version: 1.0.1

🧹 Free up disk space by cleaning caches, temp files, app leftovers, and more. Everything goes to Trash β€” nothing is gone forever unless you say so.


Screenshots

πŸ“· View all screenshots


Features

Dashboard πŸ“Š β€” disk usage chart, system info (model, CPU, RAM, macOS version), cleanup history and stats.

Smart Cleanup πŸ” β€” scans 35 categories at once:

  • App Caches β€” Google, Spotify, JetBrains, opencode, browsers (Safari, Chrome, Firefox, Edge, Brave, Vivaldi, Arc), messengers (Telegram, Discord, Slack, Signal, WeChat, Teams)
  • Package Managers β€” Homebrew, npm, yarn, pnpm, CocoaPods
  • Dev Tools β€” Xcode DerivedData, iOS Simulators (old runtimes too), Android SDK + Studio caches, Gradle/Maven, Flutter/Dart, language caches (Go, Rust, Python, Node.js, Ruby, Java, Julia, Elixir, Haskell, Swift PM, R)
  • IDE Caches β€” Cursor, VS Code (incl. Insiders), Windsurf, Zed, JetBrains, Nova, Sublime Text, Atom, Eclipse, opencode, Claude, ChatGPT, Gemini, Perplexity, GitHub Desktop, Slack, Discord, Figma, Notion, Postman, Insomnia, Linear, Tower, TablePlus + dynamic Electron cache discovery
  • System Caches β€” QuickLook, fonts, Spotlight, Siri, CloudKit, TimeMachine, icons
  • Docker β€” container and image cleanup
  • App Containers β€” sandboxed caches in Containers + Group Containers
  • Dotfile Caches β€” AI CLI tools (opencode, Claude, Gemini, Codex, Aider), dev tools (npm logs, Terraform, Helm, Bazel, ccache, vcpkg)
  • Scattered Junk β€” .DS_Store, __MACOSX, stray logs, Windows metadata (Thumbs.db, desktop.ini), broken symlinks
  • Orphaned Files β€” leftovers from uninstalled apps in HTTPStorages, WebKit, Cookies, /Users/Shared
  • Old IDE Versions β€” cleans system caches for VS Code, Cursor, Windsurf, Zed, Sublime Text, Eclipse, Atom; detects and removes leftover JetBrains cache/log directories for no-longer-installed products; cleans old Android Studio version caches (keeps latest); removes stale CachedData subdirectories for VS Code, Cursor, Windsurf (keeps latest version)
  • Large Files β€” old DMG/pkg/iso/zip installers, node_modules (recursive), iPhone backups, IPSW firmware
  • Dynamic Cache Discovery β€” auto-discovers large reverse-DNS caches in ~/Library/Caches; Apple caches (com.apple.*) at β‰₯ 5 MB, others at β‰₯ 20 MB
  • Time Machine Snapshots β€” local APFS snapshots (macOS recreates them automatically)
  • iOS Backups β€” re-downloadable from iCloud
  • Mail Downloads β€” cached email attachments
  • Saved Application State β€” window/session state (recreated on app launch)
  • Crash Reports β€” old crash logs and diagnostic files
  • AssetsV2 / iWork Templates β€” Pages/Numbers/Keynote templates (~800 MB, re-downloaded on demand)
  • iCloud CloudKit Cache β€” metadata cache (rebuilt automatically)
  • SwiftPM Cache β€” build/download cache (rebuilt on next build)
  • Carthage Cache β€” dependency cache and spec repos
  • Steam Cache β€” app cache, shader cache, depot cache, logs
  • Teams Cache β€” Electron caches (Cache, Code Cache, GPUCache, IndexedDB)
  • Adobe Caches β€” application and media caches
  • Chrome Extra Caches β€” disk cache, code cache, GPU cache, service workers

All categories are always scanned. Dev-related ones show a purple "DEV" badge. Risk badges (Safe / Moderate / Dangerous / Protected) appear after scan β€” you pick what to delete, then confirm.

Cleanup Options β€” one opt-in toggle before scan:

  • Clean .DS_Store files β€” removes Finder metadata from directories (off by default)

Process Manager βš™οΈ β€” lists running processes, lets you terminate or force-kill them. Critical system processes (kernel_task, launchd, WindowServer) are protected.

Startup Services πŸš€ β€” shows all LaunchAgents from ~/Library/LaunchAgents, their load status, and lets you enable/disable them.

App Uninstaller πŸ—‘οΈ β€” finds installed apps, scans for residual files (Caches, Preferences, Application Support, Logs), shows total space to reclaim. Expert Mode for cherry-picking leftovers.

Settings β€” light/dark/system theme, languages (English, Русский, Π£ΠΊΡ€Π°Ρ—Π½ΡΡŒΠΊΠ°), notifications, scan-on-startup, Trash behavior, and more.


How It Works

Runs on Apple Silicon (M1–M5) with full parallelism β€” cleanup categories execute concurrently across all available cores. File scanning is done with a stack-based iterator that batches work and deduplicates inodes. Size calculations are cached to avoid redundant work.


Safety πŸ›‘οΈ

  • Everything goes to Trash via trashItem(at:) β€” always recoverable
  • SafetyManager blocks access to /System, /usr, /bin, ~/.ssh, and other critical paths
  • ProcessSafetyPolicy protects system-critical processes from termination
  • Permanent deletion is opt-in and clearly marked in the UI
  • Apps are closed before cleanup (graceful terminate β†’ force-kill after 3s)
  • Full Disk Access is requested at startup

Tech Stack

  • Swift 6 β€” actors, async/await, structured task groups
  • SwiftUI β€” @Observable, NavigationSplitView, Charts
  • Build β€” XcodeGen, whole-module optimization, -O Swift flag
  • Logging β€” OSLog with structured subsystems
  • Architecture β€” feature-oriented folders, component-based cleanup

Project Structure

MacOSCleaner/
β”œ App/              # Entry point, RootView, sidebar navigation
β”œ Domains/
β”‚  β”œ Cleanup/       # Coordinator, Engine, StateMachine, ItemManager, Notifier, Models
β”‚  β”œ ProcessManagement/  # ProcessManager, ProcessSafetyPolicy
β”‚  β”” StartupServices/    # LaunchServiceManager
β”œ Features/         # SwiftUI views + ViewModels (Dashboard, Cleanup, Processes, Settings, Uninstaller, About)
β”œ Infrastructure/   # CommandRunner, SafetyManager, TrashManager, LanguageManager, PosixScanner, actors
β”œ Models/           # CleanupItem, OperationRisk, RunningProcess, StartupService, etc.
β”” Resources/        # Localizable.strings (en/ru/uk), assets

Quick Start

Requirements: macOS 15.5+, Xcode 16+, XcodeGen

cd MacOSCleaner
xcodegen
open MacOSCleaner.xcodeproj
# Cmd+R to run, Cmd+U to run tests

Building a Distributable .app

Option 1: Xcode (Recommended)

cd MacOSCleaner
xcodegen
open MacOSCleaner.xcodeproj

In Xcode: Product β†’ Archive β†’ Distribute App β†’ Copy App β†’ choose destination.

Option 2: Command Line

cd MacOSCleaner
xcodegen

xcodebuild -project MacOSCleaner.xcodeproj \
  -scheme MacOSCleaner \
  -configuration Release \
  -derivedDataPath build \
  -archivePath build/MacOSCleaner.xcarchive \
  archive

xcodebuild -exportArchive \
  -archivePath build/MacOSCleaner.xcarchive \
  -exportPath build/Export \
  -exportOptionsPlist ExportOptions.plist

Create ExportOptions.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>method</key>
    <string>mac-application</string>
    <key>destination</key>
    <string>export</string>
    <key>signingStyle</key>
    <string>automatic</string>
</dict>
</plist>

Option 3: Debug Build

cd MacOSCleaner
xcodebuild -project MacOSCleaner.xcodeproj \
  -scheme MacOSCleaner \
  -configuration Debug \
  -derivedDataPath build

Code Signing

Ad-hoc (local testing only):

codesign --force --deep --sign - "/path/to/MacOSCleaner.app"

Gatekeeper will block this on other Macs unless they right-click β†’ Open.

Developer ID (recommended for sharing):

codesign --force --deep --options runtime \
  --sign "Developer ID Application: Your Name (TEAM_ID)" \
  "/path/to/MacOSCleaner.app"

xcrun notarytool submit "/path/to/MacOSCleaner.app" \
  --apple-id "your@email.com" \
  --team-id "TEAM_ID" \
  --password "app-specific-password" \
  --wait

xcrun stapler staple "/path/to/MacOSCleaner.app"

Verify:

codesign --verify --deep --strict --verbose=2 "/path/to/MacOSCleaner.app"
spctl --assess --type execute --verbose "/path/to/MacOSCleaner.app"

Fix damaged app attributes:

sudo xattr -r -c /path/to/MacOSCleaner.app

Logs: open Console.app β†’ filter by subsystem com.alextkdev.macos-cleaner.


Feedback

Found a bug or have an idea? Open an issue β€” contributions are welcome.


License

Custom Non-Commercial License β€” free to use, study, and fork for personal or educational purposes. Commercial use and redistribution are not permitted. See LICENSE for details.