Skip to content

component remove removes an iOS runtime whose only other simulators were never used #241

Closed

Description

@V3RON

Part of #213.

Scope

An iOS runtime that Simlock installed cannot be removed today. When a runtime download ends, macOS creates about eleven simulators for it in the machine's default device set. simlock component remove counts them as users and refuses with COMPONENT_IN_USE. Seen on real hardware on main at 28ebddd: iOS 18.6, "0 Simlock devices and 11 other devices".

After this task a simulator outside Simlock's root counts as a user of its runtime only when it has been used at least once. Never-used simulators do not block a removal. Simlock still deletes none of them: after the removal they stay in the default device set as unavailable, and the result says so and how to clear them.

Technical spec

File references are to main at 28ebddd. Find code by symbol name.

Modules touched

  • src/drivers/ios/index.ts:
    • The foreign-device count used by listComponents and removeComponent: a device in the default device set counts for its runtime only when its entry in simctl list -j devices has lastUsedAt. One function decides this for both callers.
    • removeComponent: before deleting, count the default-set devices of that runtime without lastUsedAt. After a successful removal, when that count is above zero, residue gains a sentence: how many unused simulators are now unavailable, and that xcrun simctl delete unavailable clears them. When the download also stays in the asset store, residue carries both sentences.
    • Nothing is written to the default device set. No simctl delete is run there.
  • src/core/driver.ts: the doc comment on foreignDevices says it is the number of devices outside Simlock's root that count as users, and that the driver decides what counts.
  • src/drivers/android/index.ts: no change. Every AVD in the user's AVD home still counts.
  • docs/internal/adr/0010-components-have-one-owner-in-the-core.md §8: replace "no foreign one, booted or not" with the new rule: a foreign device counts when the driver says it is a user; on iOS that is a simulator that has been used at least once, because macOS creates unused ones by itself for every installed runtime. Add that unused simulators are left in place and reported.
  • docs/internal/agent-rules/safety.md rule 1: the same change in its sentence on removing a component.
  • docs/CLI.md (component list, component remove): what foreignDevices counts on iOS; that never-used simulators do not block; the residue sentence. docs/HTTP-API.md and docs/CLIENT.md where they describe foreignDevices or residue.
  • docs/internal/KNOWN-PITFALLS.md (iOS on-demand runtime downloads never actually free disk space (mobileassetd cache outlives simctl runtime delete) #79): on Xcode 26.4.1, simctl runtime delete unregisters the runtime and leaves the download in the asset store; measured on 2026-10-02 (8.9 GB asset still present two minutes after the delete).

Contract and event changes

  • None. foreignDevices and residue keep their types. On iOS foreignDevices now counts used simulators only.

Rules in play

  • ADR 0010 §8, amended here.
  • safety.md rule 1 (amended here: the default device set is still read-only) and rule 8 (ownership still comes from the record and the receipt; this task changes only who counts as a user).
  • architecture.md rule 2 (what makes a device a user is the driver's knowledge; the core only reads the count), rule 10 (one function counts, for listing and for removal), rule 13 (the ADR, the safety rule and the docs change in this PR).
  • documentation.md rule 2.
  • testing.md rules 1 to 4.

Tests

  • The iOS driver counts a default-set device with lastUsedAt as foreign.
  • The iOS driver does not count a default-set device without lastUsedAt.
  • removeComponent proceeds when the runtime's only default-set devices are unused.
  • removeComponent refuses when one default-set device of the runtime has lastUsedAt, and deletes nothing.
  • After a removal with three unused default-set devices, residue says three simulators are unavailable and names xcrun simctl delete unavailable.
  • With no unused default-set device and no asset left, the result has no residue.
  • With unused devices and the asset still in the store, residue carries both sentences.
  • removeComponent runs no simctl command that writes to the default device set.
  • listComponents and removeComponent report the same count for the same default set.
  • The Android driver still counts every AVD in the user's AVD home.

Done when

  • On real hardware: an iOS runtime installed with simlock component install is removed with simlock component remove while the simulators macOS created for it are still in the default device set. The result carries residue. Record its text in the PR, and whether the download left the asset store. Ask the maintainer before running this.
  • simlock component list on a real machine shows foreignDevices for an iOS runtime equal to the number of its default-set simulators that have lastUsedAt.
  • pnpm check is green.

Out of scope

  • Deleting any simulator in the default device set.
  • Deleting anything from the macOS asset store.
  • A different rule for Android AVDs.
  • A force flag.

Depends on

Approval

  • Approved for delivery

Written by an agent.

Activity

  1. added
    task:draft
    on Oct 2, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Oct 2, 2026
  3. github-actions commented on Oct 2, 2026

    @github-actions
    Contributor

    Now task:ready: approved, technical spec present, #221 closed.

  4. self-assigned this
    on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions