2

I am working on an Xcode project that connects to a GraphQL API. To do this, I'm using the Apollo framework .

In my project, I've installed the cocoapod that includes the Apollo framework, and then added the following run script in Xcode:

if which apollo-codegen >/dev/null; then

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

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

  cd "${SRCROOT}/${TARGET_NAME}/GraphQL"
  $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate \
    $(find . -name '*.graphql') \
    --schema schema.json \
    --output Generated/GraphQLAPI.swift
else
  echo "Skipping Apollo code generation"
fi

This is how it looks in Xcode:

enter image description here

My directory structure in Xcode looks like this:

enter image description here

I then run the following command from Terminal:

npm install -g apollo-codegen

When I then try to build my Xcode project, I unfortunately get the following build error:

/Users/JohnDoe/Library/Developer/Xcode/DerivedData/The_Game-dfpiqreyqdjocaawjrfwhrxhdosf/Build/Intermediates.noindex/The Game.build/Debug-iphonesimulator/The Game.build/Script-7851AAFF2110C71000903FAD.sh: line 12: /Users/JohnDoe/Library/Developer/Xcode/DerivedData/The_Game-dfpiqreyqdjocaawjrfwhrxhdosf/Build/Products/Debug-iphonesimulator/Apollo/Apollo.framework/check-and-run-apollo-codegen.sh: No such file or directory

Why am I getting this error?

halfer
  • 19,824
  • 17
  • 99
  • 186
syedfa
  • 2,801
  • 1
  • 41
  • 74

1 Answers1

0

The build script has changed in recent versions of apollo ios, because apollo-codegen is now part of the new apollo cli. it should reference check-and-run-apollo-cli.sh instead.

Also make sure you use the latest version of apollo (currently 0.9.2) by specifying the version in your podfile. You might also need to update your pod repo by running pod repo update.

tskulbru
  • 2,336
  • 1
  • 20
  • 38