apollo-ios: Apollo not found - cocoapods (Not Fixed)

I have the same issue as https://github.com/apollographql/apollo-ios/issues/468

However, pod deintegrate + remove derived data + clean + restart xcode did not fix for: Swift 4.2 Xcode 10.2 Apollo 0.10.1

Previously working with: Swift 4.2 Xcode 10.1 Apollo 0.9.0

I followed update guide in https://www.apollographql.com/docs/ios/installation#adding-build-step

Error:

nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local/Cellar/nvm/0.33.8/versions/node/v8.15.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.15.0` to unset it.
not found: apollo
warning: Apollo iOS requires version 1.9.x of the Apollo CLI to be installed either globally or in a local node_modules directory.
warning: Installing apollo@1.9 in your project directory to avoid version conflicts...
npm WARN saveError ENOENT: no such file or directory, open '/Users/bricepollock/src/via_ios/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/bricepollock/src/via_ios/package.json'
npm WARN via_ios No description
npm WARN via_ios No repository field.
npm WARN via_ios No README data
npm WARN via_ios No license field.

+ apollo@1.9.2
updated 1 package in 1.957s
++ npx --no-install apollo codegen:generate '--queries=./dir/file.graphql
./dir2/file2.graphql
./dir3/file3.graphql
' --schema=schema.json ../ApolloAPI.swift
not found: apollo
Command /bin/sh failed with exit code 127

I do see node_modules directory created with several dozen dependancies. Also, the Apollo command works in command line… so it should work…

Brices-MacBook-Pro% apollo
 ›   Warning: apollo update available from 2.4.4 to 2.6.2
Command line tool for Apollo GraphQL

VERSION
  apollo/2.4.4 darwin-x64 node-v11.9.0

USAGE
  $ apollo [COMMAND]

COMMANDS
  client   Check a client project against a pushed service
  help     display help for apollo
  plugins  list installed plugins
  service  Check a service against known operation workloads to find breaking changes

Following the strange commands for nvm about prefix also did not resolve my issue:

Run `npm config delete prefix` or `nvm use --delete-prefix v8.15.0` to unset it.

Brices-MacBook-Pro% nvm use --delete-prefix v8.15.0
Now using node v8.15.0 (npm v6.4.1)

Script:

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}/dir/Apollo/mid-tier-operations"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json "../ApolloAPI.swift"

Podfile

  pod 'Apollo', '= 0.10.1'

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

@designatednerd Sorry for lack of response until now, finally got some time to look at this again.

The instructions from #109 to add ~/.bash_profile did not fix the problem for us.

Instead, we updated to the latest version of Apollo-iOS using cocoapods and modified our pre-build script to install 2.16.x: of Apollo client and this continues to work on our CI, BuddyBuild.

#!/usr/bin/env bash
npm install -g apollo@2.16.x

Solved

The script checks if you have Apollo 1.9.X with Node v8.15.0

If you have Apollo@1.9.X installed on nodejs newer version you must change to 8.15.0 and install apollo again.

nvm use 8.15.0 npm i -g apollo

Try first of all

npm install -g apollo