xcodebuild command fails in Gitlab Runner

Viewed 296

I am setting up Gitlab CI in my project, xcodebuild command fails in gitlab-runner. However, the following command to clean Xcode Project works perfectly in terminal

 xcodebuild clean -workspace ~/Documents/iOS\ Projects/{ProjectName}.xcworkspace -scheme {ProjectScheme}

When I added this script to 'yml' file and pushed it to repo, gitlab job says, xcodebuild: command not found

screenshot1

Steps taken to solve this issue, but still not resolved:

  1. Provided path to same script using /usr/bin/xcodebuild, says "No such file or directory" screenshot2
  2. Xcode > Preferences > Locations > Command Line Tools set to Xcode 13.0
  3. Run xcode-select -print-path and it shows /Applications/Xcode.app/Contents/Developer, which seems to be correct, but gitlab-runner is somehow unable to find the xcodebuild. It seems gitlab-runner is confused with directory.
1 Answers

Had a similar issue when using fastlane. If you installed the runner on macOs using the official guide, try to print out the $PATH variable and check its contents. In my case it was missing a few paths which I added in a before_script block, i.e.:

before_script:
  - export PATH="/Users/MyUser/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"

Be sure to use the shell executor and the direct macOs installation, otherwise the runner won't work

Related