Command PhaseScriptExecution failed with a nonzero exit code - No such file or directory

Hello there, I have been struggling with configuring Apollo for a while now and can’t solve the problem. I am currently stuck in the code generation build step where I added a run script. I have tried several solutions such as ticking “For install builds only” which removed the problem but then the problem is that there is no API.swift file being generated.

Looking at the derived data folder it seems like the run-bundled.codegen.sh is missing. I am not sure where to get it? I do however have a run-codegen.sh maybe I have to change to that one in my run script instead? I have added an image of the problem and my run script.

Xcode version: 13.4.1
Apollo version: 1.0.5
Apollo/2.33.4 darwin-arm64

Schema is a schema.json and not schema.graphqls

`
if [ $ACTION = “indexbuild” ]; then exit 0; fi

DERIVED_DATA_CANDIDATE=“${BUILD_ROOT}”

while ! [ -d “${DERIVED_DATA_CANDIDATE}/SourcePackages” ]; do
if [ “${DERIVED_DATA_CANDIDATE}” = / ]; then
echo >&2 “error: Unable to locate SourcePackages directory from BUILD_ROOT: ‘${BUILD_ROOT}’”
exit 1
fi

DERIVED_DATA_CANDIDATE=“$(dirname “${DERIVED_DATA_CANDIDATE}”)”
done

SCRIPT_PATH=“${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts”

if [ -z “${SCRIPT_PATH}” ]; then
echo >&2 “error: Couldn’t find the CLI script in your checked out SPM packages; make sure to add the framework to your project.”
exit 1
fi

cd “${SRCROOT}/${TARGET_NAME}”
“${SCRIPT_PATH}”/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=“schema.json” API.swift`

Hi @JoshuaB3 - it looks like you’re trying to mix instructions for versions 0.x and 1.x; they are not compatible. 1.0.0 was a breaking change release and will require you to update your configuration.

The build script you’re referring to is from the 0.x (legacy) installation documentation. I recommend taking a read through the documentation for 1.0.

The build problems you’re experiencing are because:

  • run-bundle-codegen.sh no longer exists. We no longer recommend a build script phase for code generation although it is possible with the new CLI.
  • Code generation no longer outputs a single API.swift file. It’s really worth the time reading the documentation for the new code generation engine.

Schema is a schema.json and not schema.graphqls

This is supported but you’ll need to correctly configure code generation to look for that schema file.