Repository navigation
Description
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
listComponentsandremoveComponent: a device in the default device set counts for its runtime only when its entry insimctl list -j deviceshaslastUsedAt. One function decides this for both callers. removeComponent: before deleting, count the default-set devices of that runtime withoutlastUsedAt. After a successful removal, when that count is above zero,residuegains a sentence: how many unused simulators are now unavailable, and thatxcrun simctl delete unavailableclears them. When the download also stays in the asset store,residuecarries both sentences.- Nothing is written to the default device set. No
simctl deleteis run there.
- The foreign-device count used by
src/core/driver.ts: the doc comment onforeignDevicessays 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.mdrule 1: the same change in its sentence on removing a component.docs/CLI.md(component list,component remove): whatforeignDevicescounts on iOS; that never-used simulators do not block; theresiduesentence.docs/HTTP-API.mdanddocs/CLIENT.mdwhere they describeforeignDevicesorresidue.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 deleteunregisters 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.
foreignDevicesandresiduekeep their types. On iOSforeignDevicesnow counts used simulators only.
Rules in play
- ADR 0010 §8, amended here.
safety.mdrule 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.mdrule 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.mdrule 2.testing.mdrules 1 to 4.
Tests
- The iOS driver counts a default-set device with
lastUsedAtas foreign. - The iOS driver does not count a default-set device without
lastUsedAt. removeComponentproceeds when the runtime's only default-set devices are unused.removeComponentrefuses when one default-set device of the runtime haslastUsedAt, and deletes nothing.- After a removal with three unused default-set devices,
residuesays three simulators are unavailable and namesxcrun 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,
residuecarries both sentences. removeComponentruns nosimctlcommand that writes to the default device set.listComponentsandremoveComponentreport 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 installis removed withsimlock component removewhile the simulators macOS created for it are still in the default device set. The result carriesresidue. Record its text in the PR, and whether the download left the asset store. Ask the maintainer before running this. simlock component liston a real machine showsforeignDevicesfor an iOS runtime equal to the number of its default-set simulators that havelastUsedAt.pnpm checkis 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
github-actions commentedon Oct 2, 2026
Now
task:ready: approved, technical spec present, #221 closed.test(ios): an unreadable default-set entry counts as a user, and one …