XcodeCloud build fails with following error - The ci_pre_xcodebuild.sh is executable but exited with 2 exit code. Make sure a valid shebang line is specified if the file is a script and that the interpreter specified in the shebang line is supported on Xcode Cloud.
This is my script -
#!/bin/sh
if [[ $CI_XCODEBUILD_ACTION = 'build' ]]; then
brew install swiftlint
cd ..
swiftlint --strict
fi
Please let me know how can i resolve this error?
You have violations in your swift code and that's how
swiftlint
is telling you. It should be outputting those violations to the console so you can see what they are.Also
cd ..
is weak; use something likecd $PROJECT_DIR
instead:Also you should be running
swiftlint
in a pre-commit hook so such errors are can be fixed before they reach your CI.