apollo-ios: Command PhaseScriptExecution failed with a nonzero exit code
Bug report
After following the tutorial to get things setup, I’m getting the following error message:
Command PhaseScriptExecution failed with a nonzero exit code
Versions
Please fill in the versions you’re currently using:
apollo-ios
SDK version: 0.43.0- Xcode version: 12.5
- Swift version: 5.4
- Apollo CLI (npm): apollo/2.33.2 darwin-x64 node-v14.17.0
- Package manager:
Steps to reproduce
-
Created a multiplatform project with Xcode 12.5
-
Downloaded the schema.json
apollo schema:download --endpoint=http://localhost:4000/graphql schema.json
-
moved the
schema.json
to theShared
directory in Xcode -
On your application target’s Build Phases settings tab, click the + icon and choose New Run Script Phase.
-
In the created Run Script, change its name to Generate Apollo GraphQL API
-
Drag this new run script just above Compile Sources in your list of Build Phases so that it executes before your code is compiled.
-
Copy run script for Swift Package Manager
Note: Updated 2nd to the last line as follows because
schema.json
is located in theShared
directory:
cd "${SRCROOT}/Shared"
"${SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="schema.json" API.swift
- Command + B
Further details
Here’s the error that I’m seeing with Xcode when trying the build application:
Have you tried our new Swift Package Manager wrapper around codegen? It's now out of beta and ready to go! See docs at https://www.apollographql.com/docs/ios/swift-scripting/. This Bash script will be deprecated soon, so give it a try today!
Checking if CLI needs to be downloaded...
Zip file already downloaded!
Correct version of the CLI tarball is downloaded locally, checking if it's already been extracted...
Current verson of CLI is already extracted!
› Warning: apollo update available from 2.32.1 to 2.33.2.
Apollo CLI Information: apollo/2.32.1 darwin-x64 node-v10.23.1
+ /Users/conradwt/Library/Developer/Xcode/DerivedData/Flix-fmkqiqhjtebmxzadfdtntkcqpopx/SourcePackages/checkouts/apollo-ios/scripts/apollo/bin/run codegen:generate --target=swift '--includes=./**/*.graphql' --localSchemaFile=schema.json API.swift
› Warning: apollo update available from 2.32.1 to 2.33.2.
Loading Apollo Project [started]
Loading Apollo Project [completed]
Generating query files [started]
Generating query files with 'swift' target [title changed]
Generating query files with 'swift' target [failed]
→ No operations or fragments found to generate code for.
Error: No operations or fragments found to generate code for.
Command PhaseScriptExecution failed with a nonzero exit code
Reference:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (8 by maintainers)
@EMammie I highly recommend you try using the new Apollo iOS 1.0. The code generation engine has been completely rebuilt and is much more robust now.
The 1.0 version is about to come out of Beta. The release candidate is available right now at the tag
1.0.0-rc.1
. I’m in the process of writing all the documentation for the 1.0 version right now, and we will have the final 1.0 with complete documentation released by the end of the week (Sept. 30th)!Glad you got this working!
Yes, once you generate it for the first time, you’ll just need to add the file to your Xcode project manually. After that, any additional runs of code gen will edit the existing file and it will stay hooked in to your Xcode project!