Apollo-ios: Command PhaseScriptExecution failed with a nonzero exit code

Created on 23 Oct 2018  路  28Comments  路  Source: apollographql/apollo-ios

I am trying to run my project in Xcode 10.0, and while compiling the error pops up stating that the Command PhaseScriptExecution failed with a nonzero exit code.
I have updated my iPhone to iOS 12 and I am unable to run app into my own phone. Please help me. I am stuck for so long.

screen shot 2018-10-23 at 10 07 57 pm

build-issue codegen

Most helpful comment

Exec in your project "sudo chmod -R 777 YourProjectFolder"

All 28 comments

i have the same issue i already updated my Xcode 10.0 and my ipad to 12, the error still show up,
command phasescriptexecution failed with a nonzero exit code
but when i tried to build an older version of my source application it is working perfectly, anyone can help please !

I feel helpless. I am running my application in simulator since that day.

I ran into this trying to set up a project for the first time today!

I was able to fix it in project.pbxproj. There was a space at the beginning of the string

- " $(SRCROOT)/Carthage/Build/iOS/Apollo.framework",
+ "$(SRCROOT)/Carthage/Build/iOS/Apollo.framework"

When I removed the space my build succeeded.

@ioskunal, @Mohammed-Sedawei Temporal fix: Go to the last path route from the error(/Users/.......) and delete the Apollo.framework file. Remember there are one file per product (simulator and device)

I think the problem is related with .dSYM files generated from Carthage vs .framework folders.
May help: https://github.com/Carthage/Carthage/issues/1070

@mkv27 after deleting this I receive the same error and my Xcode Crashes. Any ideas? Also attaching the xcode Crash report for reference.

Xcode 10 Crash Report.txt

Could you please paste the code you are using for generate the Apollo GraphQL API?
I'm using this

# Type a script or drag a script file from your workspace to insert its path.
APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"

if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
exit 1
fi

cd "${SRCROOT}/${TARGET_NAME}"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift

@mkv27 this is already in place. But still does not work.
@martijnwalraven Can you please help here?
This is a BLOCKER.

This error occurred to me when I added Apollo to the project with cocoapods and tried to build it. I solved it by adding a .graphql query to the project. Created a simple ViewController.graphql and rebuilt the project. Then it worked.

XCode: 10.1
Pod Apollo/core: 0.9.4
node_modules/apollo: 1.9
MacOS: 10.14 Mojave

Guys I had to take the tough decision to remove Apollo from my iOS Project. It took me 3 days to migrate the network layer completely which I think is far better than waiting on this threat to wait for someone to fix.

This error was happening for me because I tried to use Carthage but ran into a different error... switched to CocoaPods, but the Carthage build artifacts were not cleaned up. To fix, I removed these 4 files/directories.

$ find . -name Apollo.framework
./Carthage/Build/watchOS/Apollo.framework
./Carthage/Build/iOS/Apollo.framework
./Carthage/Build/Mac/Apollo.framework
./Carthage/Build/tvOS/Apollo.framework

I was able to resolve this error by moving my schema.json file to the same directory as the AppDelegate.swift file. Previously I had put the file in a nested folded for code organization. As soon a I moved it, the project built without error.

I was able to resolve this error by moving my schema.json file to the same directory as the AppDelegate.swift file. Previously I had put the file in a nested folded for code organization. As soon a I moved it, the project built without error.

I'm still getting the error about 'not found: Apollo' but thanks anyways

After wasting hours, I found out the fix.
Enable automatically manage signing and development signing in targets.

@shamshiranees Hello , please can u tell me how to do it ?

@louaydhyeb
screenshot

I was able to resolve this error by remove file in Pods -> Targets Support Files -> Pods-_AppName_ -> Pods-_AppName_-frameworks.sh. After removing that file again install pod using command pod install.

Its works:
-> quit xcode,
-> install pod(again),
-> start xcode

Exec in your project "sudo chmod -R 777 YourProjectFolder"

Hey everyone, we've recently updated the setup instructions for the codgen step in build phases, which should address issues like this without having to do anything bonkers with chmod or anything like that. I'm going to close this out, please open a new issue if you're having any problems from the new setup instructions. Thank you!

Showing Recent Messages
Command PhaseScriptExecution failed with a nonzero exit code

Facing the same issue with Xcode 10.2 .
I have used below script. Please correct me if I am wrong.

APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"

if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
exit 1
fi

cd "${SRCROOT}/${TARGET_NAME}"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift

Hey @pradipwalghude please check out the updated instructions - if they are not working, please open a new issue and include info about a) What dependency management you're using and b) exactly what error you are receiving when the build fails. Thank you!

I was able to resolve this error by carthage rebuild.
may be it works bellow.

carthage bootstrap --platform iOS

@ioskunal Please check your provisioning profile and certificates

this take me around 4 hours of search but no one work. finally I think about it soo the error created after I move my project to other folder with multiple project. so when I drag it out to my desktop its work perfectly. i tried for other project also same issue there.

Hi folks, if you are still having problems with this please a) Double-check the instructions, which do change from time to time with newer versions, and b) Open a new issue if that does not help. Thank you!

I had this problem, did everything possible as cleaning the project and restarting mac but couldn't solve. At final the problem was my project directory. It has space in it. So try if there's any space in file where you've the project and do the clean with cmd+option+shift+k and cmd+b.

Try this:

Build phases > Add > New Run Script Phase

Code:

# Type a script or drag a script file from your workspace to insert its path.
# skip if we run in debug
if [ "$CONFIGURATION" == "Debug" ]; then
echo "Skip frameworks cleaning in debug version"
exit 0
fi

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

Check this answer: https://stackoverflow.com/a/64984008/7825015

Was this page helpful?
0 / 5 - 0 ratings

Related issues

farice picture farice  路  4Comments

designatednerd picture designatednerd  路  3Comments

Robuske picture Robuske  路  3Comments

marcoreni picture marcoreni  路  3Comments

Dmurph24 picture Dmurph24  路  4Comments