Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Xcode build stops with a Run Script phase that exits with code 126

ErrorA Run Script build phase returns a nonzero exit code and the build fails

Short answer

In a shell, status 126 means the command was found but is not executable. In an Xcode Run Script phase it nearly always means the script you call has no execute permission. Run chmod +x on it, and record the executable bit in Git so a fresh checkout or the CI machine keeps it.

  • Applies to Xcode 26, macOS 26, Git 2.4x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the failing Run Script step in the build log, read the line the script was running when it stopped, and check the permission bits of that file.

    ls -l path/to/the-script.sh
  2. 2Match what you see, then jump to its fix

    1. 1ls -l shows -rw-r--r-- (no x) for a script the phase calls by pathThe script file has no execute permissionFix
    2. 2The script runs on your Mac but fails after a fresh clone, on another machine or on a build serverGit did not keep the executable bit for the team or CIFix

What does the error look like?

  • A Run Script build phase returns a nonzero exit code and the build fails
  • exit code 126

Cause 1 of 2

The script file has no execute permission

1Check

The shell returns 126 when a command is found but cannot be executed. List the file mode of the script the phase runs.

ls -l "$SRCROOT/scripts/build.sh"

2Fix

Add the execute bit to the script.

chmod +x scripts/build.sh

3Verify

The mode now shows x, and a clean build passes the phase.

ls -l scripts/build.sh
xcodebuild -scheme MyApp clean build

Confirmed by gnu.org

Did this fix it?

Cause 2 of 2

Git did not keep the executable bit for the team or CI

1Check

Git records the executable bit in the index. Compare what the index stores with the working file; the first column of the listing is the mode (100755 means executable).

git ls-files --stage scripts/build.sh

2Fix

Record the executable bit in the index and commit it. The git-update-index page names this option as the workaround when the filesystem does not track the bit reliably.

git update-index --chmod=+x scripts/build.sh
git commit -m "Make build script executable"

3Verify

The index now shows mode 100755.

git ls-files --stage scripts/build.sh

Confirmed by git-scm.com

Did this fix it?

How do I stop it coming back?

  • After adding a script to the repo, run git ls-files --stage on it before the first push.
  • In the phase, list the script under Input Files so Xcode knows what it reads.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Mobile apps

App record creation fails because you lack permission

You cannot add a new app in App Store Connect as a Developer or limited user

Only the Account Holder, an Admin or an App Manager can create an app record, and Apple blocks it until the Account Holder has signed the latest agreement.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.