'xcodebuild command fails in Gitlab Runner
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
Steps taken to solve this issue, but still not resolved:
- Provided path to same script using /usr/bin/xcodebuild,
says "No such file or directory"

- Xcode > Preferences > Locations > Command Line Tools set to Xcode 13.0
- Run
xcode-select -print-pathand 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.
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ruben1691 |

