Skip to content

Automatically install simulator runtimes for chosen platforms - #856

Open
anandghegde wants to merge 1 commit into
XcodesOrg:mainfrom
anandghegde:auto-install-runtimes
Open

anandghegde wants to merge 1 commit into
XcodesOrg:mainfrom
anandghegde:auto-install-runtimes

Conversation

@anandghegde

Copy link
Copy Markdown

Fixes #298.

Manual runtime installs already exist, but you have to come back to the Platforms window after every Xcode install and start each one by hand. This adds the "pick once, always ready" half that the issue asks for.

What it does

The Platforms window gets an Install Automatically section with a toggle per platform (iOS, watchOS, tvOS, visionOS). When an Xcode install finishes, Xcodes installs the newest runtime for each selected platform through the same downloadRuntime path a manual click uses.

A platform is skipped when its newest runtime is already installed, so repeat Xcode installs never re-download a runtime that is already on disk, and nothing happens at all when no platform is selected.

Details

  • RuntimeAutoInstallService holds the decision logic: newest runtime per selected platform, version-compared (so 26.0 beats 18.5 rather than sorting as strings), already-installed platforms filtered out by matching simulatorVersion.buildUpdate against the installed CoreSimulatorImage builds — the same match PlatformsListView already uses.
  • Betas are only considered when the user has already opted into automatically installing Xcode betas (autoInstallation == .newestBeta). For everyone else only released runtimes are installed automatically; betas are still installable by hand. When prereleases are in play, a release always wins over a beta of the same version, otherwise the higher seed wins.
  • downloadRuntime(runtime:presentingErrors:) — automatic installs pass presentingErrors: false, so a runtime that can't be installed right now (for example RuntimeInstallPolicyError.noSelectedXcode, which is possible right after a first install) is logged instead of throwing an alert at the user. Manual installs keep the existing alert behaviour via the default argument.
  • Runtimes already being installed are skipped, so an auto-install can't cancel and restart an in-flight download.
  • The selection is stored under autoInstallRuntimePlatforms as a comma separated list of platform identifiers via a RawRepresentable wrapper, which means it works with @AppStorage and can also be pushed by a configuration profile — the toggles disable themselves when PreferenceKey.autoInstallRuntimePlatforms.isManaged().
  • DownloadableRuntime.icon() now forwards to a new DownloadableRuntime.Platform.icon() so the new rows can show a platform icon without a runtime instance.

installAsync previously bailed out early with a guard when the installed Xcode wasn't in allXcodes; that is now an if let so the auto-install step runs either way. Behaviour is otherwise unchanged.

Tests

15 new tests in XcodesTests/RuntimeAutoInstallServiceTests.swift cover platform selection, version ordering, the already-installed skip, the beta policy, and the preference round trip. Full suite: 66 tests, 0 failures.

Strings

Two new keys (PlatformsList.AutoInstall.Title, PlatformsList.AutoInstall.Description) with English values only — happy to leave the other locales to the usual translation pass, or to adjust the wording.

Pick the platforms you always need in the Platforms window and Xcodes
installs the newest runtime for each of them as soon as an Xcode install
finishes, instead of making you come back and start every runtime by hand.

- `RuntimeAutoInstallService` picks the newest downloadable runtime per
  selected platform and skips platforms whose newest runtime is already
  installed, so repeat installs don't re-download anything.
- Beta runtimes are only considered for users who already opted into
  automatically installing Xcode betas.
- `downloadRuntime` gained `presentingErrors:` so an automatic install that
  can't run right now (for example no selected Xcode yet) logs instead of
  raising an alert.
- The chosen platforms are stored under `autoInstallRuntimePlatforms` as a
  comma separated list of platform identifiers, so they can also be managed
  by a configuration profile.

Fixes XcodesOrg#298
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.

Automatically download optional simulators

1 participant