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 [email protected] 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.
+ [email protected]
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'
Having the same issue.
Try first of all
npm install -g apollo
I had already run npm intall -g apollo. It seems like apollo-ios is asking specifically for version 1.9.2 of the CLI. Even after running npm install -g [email protected] I get the same error.
I verified that I have the correct version on my machine using the following:
❯❯❯ apollo -v
› Warning: apollo update available from 1.9.2 to 2.8.3.
apollo/1.9.2 darwin-x64 node-v10.0.0
Even after verifying this, I still see the same error if I "cleanly" build the xcode project by deleting the node_modules directory that gets generated when the apollo iOS framework detects that no global version of the CLI is installed.
tried the npm global install instead of user.
"npm install -g [email protected]"
No change. Breaking down the wierdness:
== Wants apollo 1.9.2 instead of latest and hates prefix but commands to abide by it don't affect warnings ==
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 [email protected] in your project directory to avoid version conflicts...
== Asking for some package.json in my home dir ==
npm WARN saveError ENOENT: no such file or directory, open '/Users/name/src/repo/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/name/src/repo/package.json'
== can't find Apollo ==
not found: apollo
Command /bin/sh failed with exit code 127
Don't know where to go on this. Keeping on Apollo 0.9.0 and Xcode 10.1 for now...
I have the same issue with Apollo 0.10.0
same here
Solved
The script checks if you have Apollo 1.9.X with Node v8.15.0
If you have [email protected] 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
Thanks for the contribution @esanchezaxa
I don't have npm in my iOS directory... so this did not work for me. :(
Thanks for the contribution @esanchezaxa
I don't have npm in my iOS directory... so this did not work for me. :(
You can go to the directory where you have npm and install Apollo globally
We're now seeing this issue when building on our CI (BuddyBuild). Everything works fine on local dev machines.
/bin/sh -c /tmp/sandbox/5c8018a37a06d100012d55a4/bbtest/Build/Intermediates.noindex/SampleApp.build/Debug-iphonesimulator/SampleApp.build/Script-28C6AA2222A8750A001A4659.sh
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 [email protected] in your project directory to avoid version conflicts...
> [email protected] postinstall /tmp/sandbox/workspace/node_modules/core-js
> node scripts/postinstall || echo "ignore"
[96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
[96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
[96m>[94m https://opencollective.com/core-js [0m
[96m>[94m https://www.patreon.com/zloirock [0m
[96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
> [email protected] postinstall /tmp/sandbox/workspace/node_modules/protobufjs
> node scripts/postinstall
npm WARN saveError ENOENT: no such file or directory, open '/tmp/sandbox/workspace/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/private/tmp/sandbox/workspace/package.json'
npm WARN workspace No description
npm WARN workspace No repository field.
npm WARN workspace No README data
npm WARN workspace No license field.
+ [email protected]
added 442 packages in 21.663s
++ npx --no-install apollo codegen:generate '--queries=./Queries.graphql
./Mutations.graphql' --schema=schema.json API.swift
not found: apollo
Command PhaseScriptExecution failed with a nonzero exit code
For anyone who runs into the same issue on BuddyBuild, we fixed the problem with a "pre build" script:
Add a file named "buddybuild_prebuild.sh" in the root of your repo:
#!/usr/bin/env bash
npm install -g [email protected]
got same issue after changing brew node to nvm node.
@Dfmarulanda @jtrainer and everyone: Can you see if the solution suggested in #190 of adding a line to the top of your run script telling it to use your ~/.bash_profile file?
I'm not sure this will work for CI because I'm not entirely sure how they're setting up where node lives and all that, but I believe this should at least work locally.
Anyone have anything to report back here? I've also updated the build phase setup instructions, so that's something to check if your issue isn't directly related to NPM.
Since I haven't heard anything back here in a couple weeks and we're about to make some significant changes to codegen steps in 0.13.0 (particularly that we're going to catch back up with the current version of the Apollo CLI, which should make everyone's lives way easier), I'm gonna close this one out.
Once that ships, please open new issues for any problems you run into here. Thank you!
@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 [email protected]
Same issue
OS: MacOS Catalina 10.15.2
Xcode 10.3
Version Manager: asdf
NodeJS 12.13.1
Fixed my issue https://stackoverflow.com/a/31734090
Unless you need to use an older version for Swift 4 compatibility, I would strongly recommend updating to a newer version of both Xcode and Apollo. 0.20.0 is the current and there's a way easier way to deal with all the node nonsense set up in there.