Derived from ARCHITECTURE.md. The guiding principle is the
smallest clean refactor that generalises SideStore from one Apple account to
many, reusing the existing AuthenticatedOperationContext-driven pipeline and
matching the existing coding style. Existing single-account behaviour is a
special case (N = 1) of the new design.
- The signing pipeline already carries a per-operation
session/team/certificate. We make who fills that context account-aware instead of globally fixed. - Credentials become per-account in the Keychain, keyed by
Account.identifier. Device-level anisette state (identifier,adiPb) stays global. - Each
InstalledAppgains a permanentsigningAccountID. - Refresh partitions apps by account, runs one authenticated group per account, and aggregates results — giving failure isolation for free.
- A new
AccountManagerfacade is the single entry point the rest of the app uses; it holds no mutable global state (it reads/writes Core Data + Keychain). isActiveAccount/isActiveTeamare retained but re-interpreted as the default account (used for new installs / legacy UI), not "the only account".
| Area | Change |
|---|---|
| Data model | New model version AltStore 18: add optional InstalledApp.signingAccountID: String. Lightweight/inferred migration. |
| Keychain | Add per-account credential + session/cert/team storage keyed by account id; keep global keys for anisette + migration. |
| Context | AuthenticatedOperationContext gains accountID: String? (target account for this context). |
| Auth | AuthenticationOperation authenticates the context's accountID from per-account creds; stops nuking other accounts' active flags. |
| Install | InstallAppOperation binds the app to the signing team/account + sets signingAccountID. |
| Refresh | AppManager.refresh partitions by account into child groups + aggregate. |
| New type | AccountManager (AltStoreCore) with the required API. |
| UI | Accounts list + add/remove/status in Settings; signing-account row + change in app detail. |
Add
AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 18.xcdatamodel/contents(+ set.xccurrentversion)AltStoreCore/Managers/AccountManager.swiftAltStore/Settings/Accounts/AccountsViewController.swift(+ minimal cell/rows)docs/multi-account/*(this analysis/plan)
Modify
AltStoreCore/Model/InstalledApp.swift—signingAccountID+signingAccounthelpersAltStoreCore/Components/Keychain.swift— per-account APIAltStoreCore/Model/DatabaseManager/DatabaseManager.swift— startup backfill/migration hook; keepactiveAccount/activeTeamas "default"AltStore/Operations/Common/OperationContexts.swift—accountIDAltStore/Operations/AuthenticationOperation.swift— per-account auth + credential storeAltStore/Operations/InstallAppOperation.swift— bind signing team/accountAltStore/Managing Apps/AppManager.swift— account-partitioned refresh + aggregate group; account-scoped resign helperAltStore/Settings/SettingsViewController.swift— entry to Accounts screen (keep existing single-account rows working)- App detail (
AltStore/App Detail/…) — signing-account row + change action
- Duplicate
AltStore 17_1.xcdatamodel→AltStore 18.xcdatamodel, add<attribute name="signingAccountID" optional="YES" attributeType="String"/>toInstalledApp, bumpuserDefinedModelVersionIdentifiertov18, and point.xccurrentversionat it. Xcode 16 file-system-synchronised groups pick the new version up automatically;RSTPersistentContainermigrates via the inferred (lightweight) mapping model. - Automatic data migration (Phase 8) at startup (
DatabaseManager.prepareDatabaseor a dedicated one-shot): for everyInstalledAppwithsigningAccountID == nil, backfill it fromteam?.account?.identifier(or the active account). Idempotent. - Automatic credential migration: on first launch after update, if legacy global credentials exist and an active account exists, copy them into that account's per-account Keychain slots. Preserves the existing user's login as "Account #1".
No user loses apps or signing info: existing rows keep their team relationship and
gain a signingAccountID; existing credentials are re-homed, not recreated.
AccountManager.shared — stateless facade (no mutable stored properties):
listAccounts(in:) -> [Account]account(_ id: String, in:) -> Account?activeAccounts(in:) -> [Account]— accounts that currently have usable credentialsdefaultAccount(in:) -> Account?— theisActiveAccountaccount (new-install default)addAccount(presentingViewController:) async -> Result<Account, Error>— interactive login for a new Apple ID, stored per-accountremoveAccount(_:) async -> Result<Void, Error>— clear that account's credentials + deleteAccountupdateAccount(_:)— refresh stored profile infoaccountForApp(_ app: InstalledApp, in:) -> Account?— resolve viasigningAccountID(fallbackteam?.account)assignAccount(_ id:, toApp:)— setsigningAccountID(+ team) permanentlyrefreshAccount(_ id:, presentingViewController:) -> RefreshGroup— refresh only that account's apps
- Per-account Keychain slots:
"<accountID>.appleIDPassword"etc., plus a per-account in-memory[accountID: (session, cert, team)]cache. AuthenticatedOperationContext.accountIDselects which credentialsAuthenticationOperationloads/stores.nil= default account / interactive add.- Sessions, certificates, teams and App IDs are already isolated by context; storing them per-account completes isolation.
InstalledApp.signingAccountID(permanent). Set on install from the signing team's account.InstallAppOperationusescontext.team(the team that signed) rather thanactiveTeam.
AppManager.refresh(apps):- Resolve each app's account (
AccountManager.accountForApp). - Group apps by account id.
N ≤ 1→ existing single-group path (unchanged behaviour).N > 1→ one childRefreshGroupper account (child.context.accountID = id), run concurrently viaperform; an aggregate group merges child results, progress andbeginInstallationHandler, and fires itscompletionHandlerwhen all children finish.
- Resolve each app's account (
- Because each child has its own context/session/
error, one account's failure only fails that child's apps — other accounts keep refreshing. Apps whose account is missing/credential-less fail only themselves with a clear error.
- Settings → Accounts: list accounts with status (has valid credentials?), Add Account, Remove Account. Existing single-account rows keep working (show default).
- App detail: a row showing the current signing account + an action to change it (assign a different account, then resign).
Local xcodebuild is impossible on this Windows host, so GitHub Actions
(.github/workflows/multi-account-ci.yml, macOS) is the authoritative build/test:
buildjob:make build(archive, no signing) — full compile of every changed file.unit-testsjob:make build-tests+ the DataStructures unit-test plan.- Push after each logical milestone; fix compile errors before proceeding.
Behavioural verification (reasoned + code-level, mirroring the DoD scenarios):
single-account install/refresh/migration still work (N=1 path unchanged); install with
account A vs B; refresh A vs B apps; correct account auto-selected via signingAccountID;
failure isolation (bad creds / expired / removed account / revoked profile affect only
that account's apps).
- CI workflow (done) + docs.
- Data model v18 +
InstalledApp.signingAccountID. - Keychain per-account storage.
AccountManager.- Context
accountID+AuthenticationOperationper-account auth + credential migration. InstallAppOperationsigning-account binding + data backfill migration.AppManageraccount-partitioned refresh + aggregate + isolation.- Minimal UI (accounts management + app-detail signing account).
- Build/test hardening via CI until green.