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

Xcode and xcodebuild versions are not matching #75

Open
kstoletniy opened this issue Jan 15, 2024 · 6 comments
Open

Xcode and xcodebuild versions are not matching #75

kstoletniy opened this issue Jan 15, 2024 · 6 comments

Comments

@kstoletniy
Copy link

A few weeks ago, the workflow utilizing the macOS-13 runner unexpectedly began to fail. Prior to this, the workflow was functioning correctly, and no modifications were made to the workflow file. The failure stemmed from the fact that the Swift tool version was outdated compared to the one utilized in my project's packages. In my local project, I employ Xcode 15.2, so I specified '15.2-beta' in the workflow.

After an extensive investigation into the potential cause of the issue, I discovered that xcodebuild was pointing to version 14.3.1, leading to the problems encountered.

Three weeks ago, everything was functioning smoothly, and both the Xcode version and xcodebuild matched seamlessly. It appears that an issue was introduced recently, causing the discrepancy.

I urgently request assistance in resolving this matter as it is impeding all of my workflows.

Image version and build link
Version: 20240106.8
Included Software: https://github.com/actions/runner-images/blob/macos-13/20240106.8/images/macos/macos-13-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-13%2F20240106.8

Expected behavior
The xcode version and xcodebuild version should match always. i.e.
Screenshot 2024-01-15 at 10 31 58

Actual behavior
The xcode version and xcodebuild version are not matching versions.
Screenshot 2024-01-15 at 10 26 32

@maxim-lobanov
Copy link
Owner

Hey 👋
We didn't have any updated to this action from Sep 2023. So if workflow started to fail without changes on your side, most likely it is related to image and worth to be reported to https://github.com/actions/runner-images repo.

Could you please confirm that issue is still reproduced for you?
I can't repro it using the following workflow file:

jobs:
  build:
    runs-on: macos-13
    steps:
    - uses: maxim-lobanov/setup-xcode@v1
      with:
        xcode-version: '15.2-beta'
    - run: |
        xcode-select -print-path
    - run: |
        xcodebuild -version

I wonder if something on image side is changed again and fixed it 🤔

If it is still reproduced for you, could you run the same workflow in your repo (with xcode-select -print-path step and share logs)

@sisoje
Copy link

sisoje commented Aug 1, 2024

why not set the explicit version that user wants? I could not set 16.0.0

@jeffremer
Copy link

jeffremer commented Aug 3, 2024

Just ran into this. It's likely been failing silently for a while since we're only now bumping up from 15.1 to 15.4.

On our self-hosted runners, the workflow:

name: xcode-select
description: Uses .xcode-version to set the Xcode version
runs:
  using: "composite"
  steps:
    - id: version
      shell: sh
      run: |
        version=$(cat .xcode-version)
        echo "Setting Xcode version to: $version"
        echo "xcode-version=$version" >> $GITHUB_OUTPUT
    - uses: maxim-lobanov/setup-xcode@v1
      with:
        xcode-version: ${{ steps.version.outputs.xcode-version }}
    - name: Print Xcode version
      shell: sh
      run: |
        xcode-select -print-path
        xcodebuild -version
        swift -version

Example output:

Screenshot 2024-08-02 at 6 19 08 PM

I'm guessing the GitHub actions runners allowed sudoers or something similar, but that's not the default so our self-hosted runners have been failing silently. It'd be nice at least if the action errored out in that case.

@vanyasem
Copy link

It'd be nice at least if the action errored out in that case.

I absolutely agree

xcode-select has to be run with sudo, otherwise it fails to change Xcode version
Unfortunately it fails silently, and there is no way to know that something went wrong

Github-provided runners allow full sudo access without password, while self-hosted runners usually require entering password in order to execute commands with sudo

Disabling password for executing commands with sudo is a major security risk, and I recommend against it
You can override the default sudo behavior for a single command, allowing only that command to be executed without being prompted for the password

In our case, the command in question is xcode-select

Execute sudo visudo, and add the following lines to the sudoers file:

## No pw for xcode-select
%admin ALL=(ALL) NOPASSWD: /usr/bin/xcode-select

See https://stackoverflow.com/a/63602993 for more details

@vanyasem
Copy link

vanyasem commented Dec 16, 2024

#62 has a potential solution to change Xcode versions without xcode-select, hence eliminating the need for sudo altogether. You can upvote the issue, and the attached pull request (#63) to indicate that it matters to you.

@vanyasem
Copy link

I'm guessing the GitHub actions runners allowed sudoers or something similar

Related: #38

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

No branches or pull requests

5 participants