Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure_xcode_version uses xcversion but has not been deprecated #20866

Open
4 tasks done
mokagio opened this issue Nov 16, 2022 · 8 comments
Open
4 tasks done

ensure_xcode_version uses xcversion but has not been deprecated #20866

mokagio opened this issue Nov 16, 2022 · 8 comments

Comments

@mokagio
Copy link
Contributor

mokagio commented Nov 16, 2022

New Issue Checklist

Issue Description

#20672 deprecates xcversion in favor of xcodes. However, I noticed that the ensure_xcode_version action has not been deprecated.

Suggestion

The most straightforward course of action would be to deprecate it in favor of xcodes alone.

On the other hand, there's something nice about ensure_xcode_version which is that it merely fails the lane if the local Xcode version doesn't match the expected one without attempting an installation or version switch, something currently not possible with xcodes.

A use case for failing over switching is a CI setup where the Xcode version is controlled via a configuration setting that spins up an appropriately provisioned machine or VM and where it's best to update the configuration to match the desired version of Xcode rather than downloading it on every build.

With that in mind, an option going forward could be to update ensure_xcode_version to use xcodes under the hood. It should be possible to parse the xcodes installed output looking for "Selected" and compare with the given version or .xcode-version file.

➜ xcodes installed
14.1 (14B47b) (Selected) /Applications/Xcode.app

It might also be possible to keep the strict checking behavior.

@fastlane-bot
Copy link

It seems like you have not included the output of fastlane env
To make it easier for us help you resolve this issue, please update the issue to include the output of fastlane env 👍

@mokagio
Copy link
Contributor Author

mokagio commented Nov 16, 2022

@fastlane-bot I haven't added the fastlane env output because it's unrelated to the issue.

@mokagio
Copy link
Contributor Author

mokagio commented Nov 16, 2022

On the other hand, there's something nice about ensure_xcode_version which is that it merely fails the lane if the local Xcode version doesn't match the expected one without attempting an installation or version switch, something currently not possible with xcodes.

Update: I was wrong. This is currently possible with xcodes via the select_for_current_build_only parameter 🎉

However, there might be some additional error handling to implement

[14:11:07]: --------------------
[14:11:07]: --- Step: xcodes ---
[14:11:07]: --------------------
[14:11:07]: Running xcodes version 1.1.0
[14:11:07]: $ /opt/homebrew/bin/xcodes installed '14.0'
[14:11:07]: ▸ 14.0 is not installed.

[14:11:07]: Exit status of command '/opt/homebrew/bin/xcodes installed '14.0'' was 1 instead of 0.
14.0 is not installed.

[14:11:07]: fastlane finished with errors

Looking for related GitHub issues on fastlane/fastlane...

➡️  Improve Beta Setup
    https://github.com/fastlane/fastlane/pull/1 [closed] 1 💬
    04 Feb 2017

🔗  You can ⌘ + double-click on links to open them directly in your browser.
bundler: failed to load command: fastlane (/Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/bin/fastlane)
Traceback (most recent call last):
	46: from /Users/gio/.rbenv/versions/2.7.4/bin/bundle:23:in `<main>'
	45: from /Users/gio/.rbenv/versions/2.7.4/bin/bundle:23:in `load'
	44: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/exe/bundle:36:in `<top (required)>'
	43: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
	42: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/exe/bundle:48:in `block in <top (required)>'
	41: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/cli.rb:25:in `start'
	40: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	39: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/cli.rb:31:in `dispatch'
	38: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	37: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	36: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	35: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/cli.rb:486:in `exec'
	34: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:23:in `run'
	33: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:58:in `kernel_load'
	32: from /Users/gio/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:58:in `load'
	31: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in `<top (required)>'
	30: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/bin/fastlane:23:in `load'
	29: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/bin/fastlane:23:in `<top (required)>'
	28: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in `take_off'
	27: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/commands_generator.rb:43:in `start'
	26: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/commands_generator.rb:354:in `run'
	25: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
	24: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
	23: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
	22: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
	21: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
	20: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/commands_generator.rb:110:in `block (2 levels) in run'
	19: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
	18: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
	17: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
	16: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
	15: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
	14: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/lane.rb:33:in `call'
	13: from Fastfile:445:in `block (2 levels) in parsing_binding'
	12: from Fastfile:1187:in `ensure_xcode_version'
	11: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
	10: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
	 9: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
	 8: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:229:in `chdir'
	 7: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
	 6: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
	 5: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
	 4: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/actions/xcodes.rb:40:in `run'
	 3: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/helper/sh_helper.rb:12:in `sh'
	 2: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane/lib/fastlane/helper/sh_helper.rb:80:in `sh_control_output'
	 1: from /Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'
/Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/2.7.0/gems/fastlane-2.211.0/fastlane_core/lib/fastlane_core/ui/interface.rb:153:in `shell_error!': \e[31m[!] Exit status of command '/opt/homebrew/bin/xcodes installed '14.0'' was 1 instead of 0. (FastlaneCore::Interface::FastlaneShellError)
14.0 is not installed.
\e[0m

@mokagio
Copy link
Contributor Author

mokagio commented Nov 16, 2022

I started working on this via #20867

@rogerluan
Copy link
Member

Hi @mokagio ! 👋

Thanks for bringing this up!

There were a total of 4 actions either using xcode-install (aka xcversion) or dealing with Xcode installations somehow:

  1. xcversion (marked as deprecated already, as you mentioned)
  2. xcode_install (marked as deprecated already, as you mentioned)
  3. ensure_xcode_version, documented as partially deprecated here: https://github.com/xcpretty/xcode-install/blob/master/MIGRATION.md#3-ensure_xcode_version - the only "blocker" is really the strict: true option. Please take a look at that section 🙇
  4. xcode_select, I decided to not touch this one because right now it serves a very specific purpose and it's dependency-free, so I didn't see a point in adding a dependency behind it just to keep the implementation consistent. We can't really just deprecate it either, there's no point I think.

I made a mistaken in not documenting why I didn't deprecate ensure_xcode_version in my original PR's description, as I just left those notes in the https://github.com/xcpretty/xcode-install/blob/master/MIGRATION.md#3-ensure_xcode_version, but I hope this helps you have a little bit more context about the ensure_xcode_version action deprecation 🤗

And if you feel like working on its deprecation, that would be super helpful! Feel free to tag me for review if you decide to do it, I'd be happy to help you review it! 😊

@mokagio
Copy link
Contributor Author

mokagio commented Nov 17, 2022

Thanks for the additional info @rogerluan !

Gotcha.

The non-strict version checking is indeed challenging to port over. Not sure if you knew, but xcversion also supported .xcode-version files such as ~> 14.0 which xcodes does not (as far as I'm aware) and that only adds more complexity to the mix 🙃

@rogerluan
Copy link
Member

such as ~> 14.0

I didn't know that! But it makes sense now, looking in hindsight, because it uses the Ruby's (I think native?) Gem Version resolution, which accepts that syntax. Since xcodes is written in Swift, we don't have that built-in behavior, we'd probably have to find an equivalent version resolver (via SPM) or build our own in Swift 🤔 (or bridge Ruby code into the Swift CLI lol)

Definitely something we could take a look at. Thanks for bringing this up!

@rogerluan
Copy link
Member

I started a discussion here XcodesOrg/xcodes#246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants