XcodesOrg / xcodes

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

Feature Request: Add ability to print the Xcode path of a given version #219

Closed rogerluan closed 1 year ago

rogerluan commented 1 year ago

Hey 👋

In order to support fastlane's xcversion behavior of selecting a specific Xcode version just during the lifecycle of the current fastlane lane, we could use some tooling that enabled xcodes to print the Xcode path for a given version.

The related code in fastlane can be found here: https://github.com/fastlane/fastlane/blob/272063487b02b52510bb83172827fcbc336f4a55/fastlane/lib/fastlane/actions/xcversion.rb#L9 - as you can see, xcode-install (aka xcversion) has a function that returns an instance of "xcode" and sets its path as being the current DEVELOPER_DIR to be used by fastlane. If we had something similar in xcodes, then users wouldn't have to enter the sudo password at all when temporarily selecting the Xcode version just for the current build.

We could, alternatively, parse the response printed by xcodes installed as a raw string, regex it using something like:

xcode_paths_regex = /\s([\w\/\-\.\s]+)$/

But that wouldn't be reliable/scalable. I'd be concerned that any type of change in the way we log this could potentially break the regex and thus these 3rd party integrations (namely: fastlane).

I'll open a PR with a proposal 🙏