apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.87k stars 717 forks source link

Command PhaseScriptExecution failed with a nonzero exit code (XCode 15) #3300

Closed muhammadabbas001 closed 9 months ago

muhammadabbas001 commented 9 months ago

Summary

I got a non-zero exit code and could not create the Swift file using the schema.json and .graphql files.

Folder Structure

Screenshot 2023-12-11 at 2 46 10 AM

.graphql File Code

query ExampleQuery {
  genres
}

Script

# Go to the build root and search up the chain to find the Derived Data Path where the source packages are checked out.
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

# Grab a reference to the directory where scripts are checked out
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}/Base"
"${SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/ExampleQuery.graphql --localSchemaFile="schema.json" API.swift

If I print the directory at the end of that script then I get the following result. Command

echo "error: Current Directory $(pwd)"

Result: Current Directory /Users/apple/Documents/X/X/Base

One thing more, I also tried to enable the For install builds only option, and then the code ran successfully but the issue remained there and the .swift file also could not generated.

Screenshot 2023-12-11 at 2 54 08 AM

So, what could be the issue there? I tried my best to resolve that issue but could not do that right now. How to resolve that issue?

Version

1.7.1

Steps to reproduce the behavior

Screenshot 2023-12-11 at 3 02 40 AM

Logs

No response

Anything else?

No response

calvincestari commented 9 months ago

Hi @muhammadabbas001 - you said you're using version 1.7.1 but in your script it looks like you're still trying to use the legacy run-bundled-codegen.sh script which is not supported anymore. You should instead use the Codegen CLI.

If you want to continue using the script you will need to go back to the 0.x versions but I strongly recommend migrating to the latest version. The migration guides are all here.

muhammadabbas001 commented 9 months ago

@calvincestari Thanks for your kind support.