Skip to content

Use .xcode-version file #47

@acevif

Description

@acevif

I am using fastlane and chxcode, and they read Xcode's version from the .xcode-version file.

How about making this action read version from the file?

If it comes true, the '.xcode-version' file becomes SSOT, Single Source of Truth for the version of Xcode.
I think it could become a part of the best practice for iOS engineers.

Thanks.

Activity

maxim-lobanov

maxim-lobanov commented on Feb 14, 2023

@maxim-lobanov
Owner

Hi 👋 ,
One possible problem that I see here is different syntax format.

This action uses semver notation. Fastlane docs describes the different notation (Gem::Version notation I guess?).
For example:

  • 8.1 will be resolved to 8.1.0 by fastlane and as 8.1.* (for example 8.1.2 as latest available) in this action
  • ~> 8.1.0 is not semver notation and won't work at all. And I guess some other differences

it can cause confusion and different selected Xcode. Correct me if I am wrong.

bobergj

bobergj commented on Feb 21, 2023

@bobergj

@maxim-lobanov:

Fastlane docs describes the different notation ([Gem::Version notation (https://www.rubydoc.info/github/rubygems/rubygems/Gem/Version) I guess?).

I believe the idea of the .xcode-version file comes from the (now defunct) fastlane ci project: https://github.com/fastlane/ci/blob/master/docs/xcode-version.md, and in the examples there only a plain version number string is allowed, not any match syntax such as ~> 8.1.0.

Also https://github.com/klaaspieter/chxcode, mentioned above, just matches on a plain string as far as I can see.

To alleviate this confusion, we could even add a (proposed) canonical description of the .xcode-version file format to this repo. Especially so since is https://github.com/fastlane/ci/blob/master/docs/xcode-version.md is archived.

8.1 will be resolved to 8.1.0 by fastlane and as 8.1.* (for example 8.1.2 as latest available) in this action

I think we could see this as a bug in fastlane, and that setup-xcode is doing the right thing.
Edit: we could also have setup-xcode output a warning to the github action log in this case.

Related, there's also use of a .swift-version file in the community, for example by SwiftFormat: https://github.com/nicklockwood/SwiftFormat/blob/master/README.md#swift-version
It could be interesting to make setup-xcode select an Xcode version based on .swift-version if .xcode-version isn't present.

mplorentz

mplorentz commented on Aug 15, 2023

@mplorentz

FYI if you want to get this feature right now you can use @bobergj's fork. Replace

       - uses: maxim-lobanov/setup-xcode@v1
         with:
           xcode-version: 14.3

with

- uses: nomasystems/action-xcode-select@v0.1

in your Github Actions workflow yaml.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @bobergj@mplorentz@acevif@maxim-lobanov

      Issue actions

        Use `.xcode-version` file · Issue #47 · maxim-lobanov/setup-xcode