App: Add safe Xcode UserData cache cleanup#61
Open
alexandre-g wants to merge 1 commit intovashpan:masterfrom
Open
App: Add safe Xcode UserData cache cleanup#61alexandre-g wants to merge 1 commit intovashpan:masterfrom
alexandre-g wants to merge 1 commit intovashpan:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UserData Cachecleanup category for safe, regenerable Xcode data under~/Library/Developer/Xcode/UserDataPreviewsIB Support/Simulator DevicesCapabilitiesuser-data-cacherecalculateSize()semanticsWhy
Xcode stores a meaningful amount of disposable data outside the app’s existing cleanup categories, especially in preview-related
UserDatafolders. Those directories can grow very large over time, but they are safe to regenerate and are good candidates for cleanup.While adding support for those folders, scan performance became noticeably slower because some large directory trees were being traversed twice in a single scan:
This PR keeps the existing behavior and ordering, but removes that duplicate work in the scan path without weakening the semantic contract of the general-purpose size recalculation APIs.
The feature was requested in this Issue: #60
And also expected to be working on reddit
What changed
XcodeFiles.Location.userDataCacheUserData Cacheroot entry in the scan modelscanUserDataCacheLocations()to discover only explicit, regenerable cache folders underXcode/UserDatauser-data-cacheREADME.mdandDevCleaner/Resources/Manual/manual.htmlto describe the new cleanup categoryXcodeFileEntry.recalculateSize()to fully recompute child sizesSafety
This change is intentionally conservative. The new cleanup category targets only well-scoped, regenerated Xcode cache folders and does not include:
UserDatacontent that may be expected to survive across Xcode launchesPerformance notes
The scan optimization is deliberately isolated to the scan flow:
recalculateSize()still means “force recompute”This preserves API clarity while improving scan time for both:
UserData CachesectionDerived Datathat precompute child sizes for sortingTest plan
xcodebuild -project "DevCleaner.xcodeproj" -target "DevCleaner" -configuration Debug buildUserData Cachesection appearsUserDataimplementationuser-data-cacheappears as a supported clean target