Thanks for taking a look. This is a disk cleaner — code here deletes people's files, so a few of the rules below are firmer than usual.
git clone <repo> && cd iCleaner
./build.sh --run # build, assemble the .app, launch it
swift test # the engine has unit tests; the UI does not
./setup-signing.sh # once, so Full Disk Access survives rebuildsRequires macOS 13+ and Xcode 16 or matching Command Line Tools
(Package.swift is swift-tools-version 6.0).
Sources/iCleanerCore/Trash.swift is the single gate every deletion goes
through. validate() refuses, in order: paths outside the home directory,
protected standard directories, things already in the Trash, missing paths,
and symlinks.
If you add a new way to delete something, it must call validate() first.
Do not add a second path, do not add an "internal, trusted" shortcut, and do
not relax a check to make a feature work — the feature is wrong, not the
check. TrashSafetyTests and ForceDeleteTests exist to keep this true; a PR
that changes them needs to say why in the description.
These are all things that have already cost someone a day:
- Never rename
ScanCategorytoCategory. It collides with the Objective-C runtime'sCategorytypedef and produces dozens of unrelated compiler errors. .frame(min…)must always come with amax…, andmaxalone does not stop a child from over-reporting its size — seeContentView.swift, where aGeometryReaderpins the detail area for exactly this reason.- UI strings are English source strings used directly as keys. Add a new
L("…")and you must add the same key to bothResources/en.lproj/Localizable.stringsandzh-Hans.lproj, orLocalizationTestsfails. - Logs are always English and never go through
L(). Paths are logged.private, counts and durations.public. SeeAppLog.swift. - A View that shows localized text must observe
storeor@Environment(\.locale).L()is invisible to SwiftUI's dependency graph, so a view with no changing input never re-renders on a language switch.Theme.swiftexplains this at the top. - Rows laid out horizontally must be compressible:
.lineLimit(1)+ truncation +.frame(minWidth: 0)+.layoutPriority(0)for text,.fixedSize()for buttons. One stubborn row can widen the detail area and squeeze the sidebar out of the window.
And a few that are less about SwiftUI and more about not repeating an afternoon someone already lost:
- Never run a global find-and-replace over Swift here. Two separate
incidents: renaming
Categoryalso hit every.category, and replacing an unuseddetailvariable hit an identically-shaped loop in another function.grep -nfirst, then replace with enough surrounding context to be unique. - No mixed-type ternaries inside a ViewBuilder or a sort closure — the type checker gives up with "unable to type-check this expression in reasonable time". Write the closure out with explicit types.
- No bare
%in a.stringsvalue. Write%%, or make it a real format string with arguments. import osin every file that touchesAppLog— Swift imports are per-file.- Never add
.clipped()to the root frame.NavigationSplitViewis meant to draw past the title bar; clipping cuts the top 52pt, which is the first sidebar row and the entire detail header. - In shell scripts,
$VARfollowed by CJK punctuation must be${VAR}. In a non-UTF-8 locale bash swallows the first byte of the punctuation as part of the variable name andset -uaborts. Check with:grep -nP '\$[A-Za-z_][A-Za-z0-9_]*(?=[^\x00-\x7f])' *.sh
DOCS/DESIGN.md covers what the app is meant to be and why (§12 is the
decision log); DOCS/TECH_SPEC.md covers how it is built.
- Keep the diff to one concern.
swift testmust pass. If you touch scanning or deletion, add a test.- UI changes: include a before/after screenshot. Keep the window at a consistent size so the two are comparable — the README shots are 1280×800.
- English in code, comments and commit messages.
Include your macOS version, whether Full Disk Access is granted, and the version from Settings → About. Logs help a lot:
log stream --predicate 'subsystem == "local.icleaner.app"' --level infoPaths are redacted as <private> in logs by default — that is intentional.
If you can reproduce with a path you are willing to share, say so in words
rather than pasting a log you have not read.
Please do not file an issue that includes a path you would not want public. This project deletes files; issues are the wrong place for a directory listing of your home folder.