Xcode warns that a Run Script phase runs on every build
Run script build phase 'Module' will be run during every build because it does not specify any outputs.Short answer
Xcode runs a Run Script phase on every build when it has no input files, no output files, changed inputs or missing outputs. The warning appears for the no-outputs case. Give the phase at least one input and one output file that really exists after it runs, and the warning goes and the script only runs when needed.
Fix it fast
1Find out which cause you have
Find which phase the warning names and look at its Input Files and Output Files lists in the project file.
grep -n -B2 -A12 "PBXShellScriptBuildPhase" MyApp.xcodeproj/project.pbxproj2Match what you see, then jump to its fix
- 1
The warning names the phase and the Output Files list is emptyThe phase declares no output fileFix - 2
An Output File is listed, but the warning or the repeated run staysThe declared output is never created, so it always counts as missingFix - 3
Outputs are declared, but Xcode keeps running the phaseA script with no real input still needs an input fileFix
- 1
What does the error look like?
Run script build phase 'Module' will be run during every build because it does not specify any outputs.
Cause 1 of 3
The phase declares no output file
1Check
Open Build Phases for the target and expand the Run Script phase. Apple lists the conditions that make Xcode run a script: no input files, no output files, changed inputs, or missing outputs.
grep -n "outputPaths\|inputPaths" MyApp.xcodeproj/project.pbxproj2Fix
Add one input file and one output file. If the script produces nothing, make it create a small static file and list that file as the output.
# Output Files:
$(DERIVED_FILE_DIR)/script-ran.stamp
# last line of the script:
touch "${SCRIPT_OUTPUT_FILE_0}"3Verify
Build twice. The second build skips the phase and shows no warning.
xcodebuild -scheme MyApp -destination 'generic/platform=iOS Simulator' build 2>&1 | grep -i "every build"Confirmed by developer.apple.com
Cause 2 of 3
The declared output is never created, so it always counts as missing
1Check
After a build, check whether the file at that path exists. A script whose declared outputs are missing is run again on the next build.
xcodebuild -scheme MyApp -showBuildSettings | grep " DERIVED_FILE_DIR "
# then list that folder with ls -l and look for the declared file name2Fix
Make the script write exactly the declared path, preferably through the SCRIPT_OUTPUT_FILE_0 variable Xcode sets for the first output.
mkdir -p "$(dirname "${SCRIPT_OUTPUT_FILE_0}")"
./tools/generate.sh > "${SCRIPT_OUTPUT_FILE_0}"3Verify
Build twice and confirm the script log appears only the first time.
xcodebuild -scheme MyApp -destination 'generic/platform=iOS Simulator' buildConfirmed by developer.apple.com
Cause 3 of 3
A script with no real input still needs an input file
1Check
Apple says a script without any input files runs every time, even if it does not need one.
grep -n "inputPaths" MyApp.xcodeproj/project.pbxproj2Fix
List a file that never changes as the input. For many files, use a file list with the .xcfilelist extension, one path per line.
# Input Files:
$(SRCROOT)/Scripts/generate.sh3Verify
Build twice; the second build must not run the phase.
xcodebuild -scheme MyApp -destination 'generic/platform=iOS Simulator' buildConfirmed by developer.apple.com
How do I stop it coming back?
- Add input and output files to every new Run Script phase when you create it.
- Prefer a file list (.xcfilelist) when the set of files changes often.
- Treat build warnings as errors in CI so a new script without outputs is caught early.
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
Xcode cannot find a build input file that a script should create
Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
Xcode's build system plans every step from declared inputs and outputs.
3 causes, each with a fixMobile apps
Cannot change the App Privacy answers in App Store Connect
Publish Your App Privacy Responses?
Only the Account Holder, Admin and App Manager roles can answer the App Privacy questions.
2 causes, each with a fixMobile 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 fixMobile apps
You cannot find the button to pull your app back from review
No 'remove this version from review' message appears on the version page
There is no button called Reject Binary.
3 causes, each with a fixMobile apps
Your Apple Account cannot sign in to App Store Connect
Sign-in to App Store Connect is refused for an account that should have access
App Store Connect does not open to every Apple Account.
3 causes, each with a fixMobile apps
Apple rejected the app under Guideline 4.3, Design: Spam
Guideline 4.3(b) - Design - Spam
Guideline 4.3 is Apple's duplicate rule.
5 causes, each with a fix