Maxence
Maxence

Reputation: 23

Error in run script phase: framework is a directory

I'm using the apollo framework for GraphQL that I installed using Carthage but I have an error when I run the script to generate the API.swift file during the build phase.

The error is

> [myproject]/Carthage/Build/iOS/Apollo.framework: is a directory
  Command /bin/sh failed with exit code 126

I did added the script like in the apollo doc :

Here is the script itself:

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

Of course, I have also generated the schema.json beforehand

Upvotes: 2

Views: 844

Answers (1)

mkko
mkko

Reputation: 4532

Might be a bit late to answer but at least on my machine APOLLO_FRAMEWORK_PATH gets evaluated to two frameworks (iOS and watchOS) and thus running the bundled script with $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh fails.

Assuming the scripts don't differ (as of version [email protected] they don't) you can add -print -quit to the end of the find command to make it return only one result.

The full script will be:

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

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

Upvotes: 1

Related Questions