A script that works in your terminal can fail in Xcode Cloud because the cloud workflow has its own settings and script phases. Start by checking whether the intended script ran for the exact workflow that failed, then determine whether it received a nonempty value. Keep credentials out of that diagnostic.


Prove the script ran


Open the run log and read the workflow name, selected project or workspace and the failing action. Apple supports custom scripts with specific filenames in the ci_scripts directory next to the project or workspace. If your repository contains a workspace in ios and a package at its root, check which location the configured build actually uses. Local shell startup files do not establish that a variable is present in the cloud.


Add a harmless marker that identifies the script phase and verifies it started. If no marker appears, compare the committed script path and name with Apple’s documented discovery rules. Check the run’s branch and commit before moving files.


Separate a missing value from a script bug


Configure the custom variable on the workflow that ran and check the exact spelling in your script. When you need to test injection, pair a harmless variable with an explicit present-and-nonempty check for the real variable. Emit only a fixed status message. A current shell variable can also disappear at a boundary if a child script or separate phase expects a value you computed earlier. Treat a value you set inside a script and a variable set in the workflow as separate inputs to verify.


For example, a nightly archive might fail while a pull request build succeeds. Compare the two workflows and the actions they ran. Add the intended variable to the nightly workflow if absent, and verify the archive step can read it. Avoid copying settings wholesale from another workflow if most of them have no role in the archive.


Verify the repair without printing secrets


Run the corrected workflow once on your chosen test branch. In the log confirm the script marker, the fixed presence message and the build result. Remove temporary diagnostics if they no longer help. For sensitive values use Xcode Cloud’s secret option and keep the script from echoing values or arguments. This guide is based on Apple documentation and the scenario is illustrative.


Official reference