XcodesOrg / xcodes

The best command-line tool to install and switch between multiple versions of Xcode.
MIT License
3.6k stars 120 forks source link

[feature] `download` subcommand for `runtimes` #262

Closed marc-48k closed 1 year ago

marc-48k commented 1 year ago

It would really useful if it were possible to download runtimes without actually installing them. Like we can with Xcode versions.

i.e. xcodes runtimes install "iOS 15.5"

I would imagine this command to mount the DMG and extract the PKG to ~/Downloads.

StevenSorial commented 1 year ago

Curious to know what are your use cases for this. Images before iOS 16.0 are not very useful because they don't have a user-facing way for installation. The PKG inside the DMG is not usable and will fail during installation.

oonoo commented 1 year ago

Not sure what the intention of the original author is, but here would be mine: Suppose we had a way to only download a runtime and another command to only install a locally available runtime. In that case, we could cache the runtimes somewhere (some server in the local network). The command to install the runtime would need to re-package the runtime image for older runtimes If I understood it correctly.

We have issues with the current way to download and install the runtimes in one step directly from Apple. If the issue is the download from Apple, it could solve our problems.

StevenSorial commented 1 year ago

Agreed, your use case would use the DMG, not PKG. The PKG is basically useless, that is why I was asking.

In the meantime, if you pass the --keep-archive flag, the DMG would not be deleted, so if you run install again, the DMG would be found, and not downloaded.

oonoo commented 1 year ago

Agreed, your use case would use the DMG, not PKG. The PKG is basically useless, that is why I was asking.

Are you saying it would be impossible for the older runtimes? Why is the PKG useless?

marc-48k commented 1 year ago

@oonoo hit the nail on the head. What I'm looking for is a two-step download and install process similar to what we have for Xcode versions.

I would be looking to cache the DMG on the local network.

(🤔 I wasn't actually aware the PKG wasn't re-usable.)

EDIT: 🤦 I made a mistake in the original request the snippet should be: xcodes runtimes download "iOS 15.5"

oonoo commented 1 year ago

I think I understood it a little bit now: for the older runtimes a DMG is downloaded and then the PKG from inside this DMG is somehow changed (re-packaged) and installed. For saving and reusing these older runtimes, the DMG would need to be saved. And for installation, this re-packaging would need to be done on the local computer where the runtime should be installed.

StevenSorial commented 1 year ago

think I understood it a little bit now

Exactly yes. The DMG is the important file here that can be reused by xcodes, for old and new runtimes. You can achieve similar results to the download command by using the --keep-archive flag with the install command, next time xcodes will find the DMG and will skip downloading.

oonoo commented 1 year ago

But would that work if the downloading xcodes app is not the same one as the installing xcodes app? Like on different computers? Could I just copy the DMG to a specific folder and xcodes would install it without downloading?

oonoo commented 1 year ago

I found this line which checks if the DMG is already downloaded: https://github.com/RobotsAndPencils/xcodes/blob/a2039d62ce76045a56653d0c9e8bfc42b1cc44fa/Sources/XcodesKit/RuntimeInstaller.swift#L189

So I need to copy the DMG to this destination:

let url = URL(string: runtime.source)!
let destination = destinationDirectory/url.lastPathComponent

That could work I guess if this url.lastPathComponent stays stable. Hummmm

StevenSorial commented 1 year ago

yes, it should work, just put them in the directory specified in the --directory option, which is ~/Downloads by default.

oonoo commented 1 year ago

Just confirming that this workaround works!

MattKiazyk commented 1 year ago

Thanks for the responses @StevenSorial - I'll keep this open as a feature add to include a xcodes runtimes download option, similar to xcodes download