Skip to content

xcode: list and delete simulator runtimes via simctl - #147

Merged
momenbasel merged 3 commits into
momenbasel:mainfrom
omartio:feature/simctl-runtime-cleanup
Aug 12, 2026
Merged

momenbasel merged 3 commits into
momenbasel:mainfrom
omartio:feature/simctl-runtime-cleanup

Conversation

@omartio

@omartio omartio commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Surface downloaded runtimes in Xcode Junk, delete through simctl runtime delete, and auto-select outdated ones on Smart Scan. Gracefully skip when xcrun is missing; covered by unit tests.

Type of change

  • Bug fix
  • New feature
  • Performance improvement
  • UI/UX enhancement
  • Documentation
  • Other (describe)

Testing

  • Tested on macOS Ventura (13.x)
  • Tested on macOS Sonoma (14.x)
  • Tested on macOS Sequoia (15.x)
  • Tested on macOS Tahoe (26.5.2)

Screenshots

CleanShot 2026-08-05 at 22 45 20@2x

@momenbasel

momenbasel commented Aug 10, 2026 •

Copy link
Copy Markdown
Owner

Good idea and the plumbing is sound routing deletion through simctl runtime delete instead of unlinking the image is the right call, and surfacing multi-GB runtimes is worth doing. Four things to fix first.

1. --outdated is not a simctl flag. ScanEngine.swift:527 runs xcrun simctl runtime delete --outdated --dry-run. On Xcode 26.6 that exits 117 with simctl: unrecognized option '--outdated'; the string does not exist in the binary. The headline auto-select feature never fires, and the failure is swallowed because the exit status is never checked. Either drop the auto-select machinery or replace it with something supported.

2. Auto-selecting multi-GB downloads does not match how this app behaves. SimulatorRuntimeSupport.swift:113 sets isSelected: isOutdated && runtime.deletable. Nothing else here auto-selects anything that is only recoverable over the network — large files, Time Machine snapshots, Docker prune all ship unselected. Please flip it to false.

3. isXcrunAvailable() does not detect what it thinks. SimulatorRuntimeSupport.swift:22 checks isExecutableFile(atPath: "/usr/bin/xcrun"), but that is a base-OS shim present on every Mac regardless of whether developer tools are installed. On a machine with no Xcode this triggers Apple's command-line-tools installer dialog during a routine scan. Gate on xcode-select -p succeeding instead.

4. Failed deletes give the wrong advice. CleaningEngine.swift:102 puts simctl items into survivingItems, so a CoreSimulator refusal surfaces as "needs Full Disk Access - Grant Access", which can never resolve it.

Also drop the project.pbxproj edits — project.yml globs the PureMac directory and CI regenerates the project, so they are noise.

Worth noting for rebasing: 2.9.5 removes the Universal Binaries and Language Files categories, which touches Models.swift and ScanEngine.swift.

Surface downloaded runtimes in Xcode Junk, delete through
`simctl runtime delete`, and auto-select outdated ones on Smart Scan.
Gracefully skip when xcrun is missing; covered by unit tests.

Co-authored-by: Cursor <[email protected]>
@omartio
omartio force-pushed the feature/simctl-runtime-cleanup branch from eec0bac to f223285 Compare August 11, 2026 17:34
@omartio

omartio commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Hi @momenbasel
Thanks for your review.
I fixed issues and also run scenario on macOS Sequoia. Everything is good.

momenbasel and others added 2 commits August 12, 2026 08:27

@momenbasel momenbasel left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the updated branch as part of an automated maintainer pass — all four points from the previous review are properly addressed:

  1. The unsupported --outdated machinery is gone entirely; no auto-select probing remains.
  2. makeCleanableItems now hard-codes isSelected: false with testMakeCleanableItemsNeverAutoSelectsRuntimeDownloads locking the policy in. Matches how every other network-recoverable item ships.
  3. isXcrunAvailable() now gates on xcode-select -p exit status (injectable for tests) — no more CLT installer dialog risk on Xcode-less Macs.
  4. Failed simctl deletes now surface real, actionable errors ("Simulator services unavailable — open Xcode once…"), and isActionItem keeps virtual items out of the surviving-items FDA loop. Bonus: this also stops a failed Docker prune from producing the same bogus "Grant Access" advice.

Also verified independently on this end:

  • Parsed a live simctl runtime list -j from Xcode 26.6 — every field assumption in parseRuntimeListJSON (UUID-keyed dict, sizeBytes, deletable, ISO8601 lastUsedAt) matches real output, which surfaced an 8.8 GB iOS 18.6 runtime here. Deletion routes exclusively through simctl runtime delete <uuid> — no filesystem paths are constructed or unlinked, so data-loss surface is limited to a re-downloadable image, and only ever by explicit user selection.
  • Full suite green locally on the branch after updating it: 19/19 tests pass (9 new runtime tests + localization parity across all 10 catalogs).

Maintainer changes pushed to your branch (thanks for enabling edits):

  • Merged current main in and union-resolved Localizable.strings conflicts with #145 (its Smart Care block + your "Simulator runtime" key now coexist; parity re-verified at 396 keys × 10 catalogs).
  • Fixed the six README files, which still advertised "outdated runtimes are auto-selected on Smart Scan" — stale after fix (2), since nothing is auto-selected anymore.

Merging via squash. Solid feature — multi-GB runtimes were the biggest blind spot in Xcode Junk. Thanks @omartio!

— automated maintainer pass on behalf of @momenbasel

@momenbasel
momenbasel merged commit 2f79a64 into momenbasel:main Aug 12, 2026
momenbasel added a commit that referenced this pull request Aug 12, 2026
… conflict resolution (#150)

Co-authored-by: momenbasel <[email protected]>
Co-authored-by: Cursor <[email protected]>
momenbasel added a commit that referenced this pull request Aug 12, 2026
…ump 2.9.7

Ships the simctl runtime listing/deletion feature (#147), the pt-BR Smart
Care dashboard translations (#145), the full French localization (#129),
and the Xcode Junk description key restoration (#150), all already merged
to main. Regenerated project picks up the new source and strings files.

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants