Comments (48)
I experienced multiple errors while attempting to get the auto generation working. Including the following:
- An already open current issue involving whitespace #33
- Removing all whitespace in names from my targets, schemas, and build configurations, followed by re-running pod install, and cleaning resolved this.
- Afterwards, I received an error saying that
Apollo.framework
does not support the latest version ofapollo-codegen
.
- I had to downgrade the
apollo-codegen
version installed on my machine to 0.18.8 from the current latest of 0.19.1.
- Finally afterwards, I got the error which brought me to this thread:
TypeError: Cannot read property 'length' of undefined
at Object.yargs.command.command.command.argv [as handler] (/usr/local/lib/node_modules/apollo-codegen/src/cli.js:186:17)
at Object.runCommand (/usr/local/lib/node_modules/apollo- codegen/node_modules/yargs/lib/command.js:235:44)
at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:1013:30)
at Object.get [as argv] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:957:21)
at Object.<anonymous> (/usr/local/lib/node_modules/apollo-codegen/lib/cli.js:197:5)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
Command /bin/sh failed with exit code 1
@shelldonhu's suggested fix of adding a .graphql
file fixed it for me. Something in the generation script doesn't fail gracefully or the documentation is possibly out of order (it says to verify API.swift
is generated before saying to add a .graphql file).
Hope this helps someone.
from apollo-ios.
It can be built successfully when I firstly create an empty .graphql file on ${SRCROOT}/${TARGET_NAME}.
from apollo-ios.
@NiltiakSivad, thank you! I spent lot of time to find the issue! And finally, I came across with @NiltiakSivad answer. Apollo team should warn their audience about such possible case in installation tutorial!
from apollo-ios.
@jzhw0130: I still don't know what causes that for some people, but now that I think of it, we may have a workaround in recent versions of apollo-codegen
.
Could you try replacing the last line of the build script with:
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate '**/*.graphql' --schema schema.json --output API.swift
from apollo-ios.
Could you have a look at the command arguments in the build output (see screen shot)?
from apollo-ios.
@martijnwalraven it only displays +exec apollo-codegen
...weird. Any ideas why is this happening?
from apollo-ios.
@attheodo: It seems like check-and-run-apollo-codegen.sh
somehow isn't picking up the rest of the arguments. Are you sure this is the last line of the build script:
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift
from apollo-ios.
This is exactly what's inside the 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}"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift
from apollo-ios.
Not sure what could be going on here then. So the command output is just +exec apollo-codegen
, without generate
or any of the other arguments?
from apollo-ios.
from apollo-ios.
Anything special about the name of the directory the project or the target is in maybe? I'm just guessing now, no idea why that would cause this behavior.
from apollo-ios.
@martijnwalraven not really
$ pwd
/Users/thanosth/Documents/dev/waldo/WaldoMini/WaldoMini
By deleting and re-adding the script I somehow arbitrarily got it to work. It compained about not finding schema. But then, subsequent builds was just not spitting any errors, still ignoring the rest of the arguments.
Does that tell you anything?
from apollo-ios.
@attheodo: Have you been able to get this to work, or do you still experience the same issue? Really no idea what could be causing this.
from apollo-ios.
from apollo-ios.
@attheodo: I'm sorry to hear that. You mentioned you did get it to work at some point. Is there any way you can retrace your steps and find out what changed?
from apollo-ios.
@martijnwalraven I still have the same issues in a different project. Any help on how I could debug this?
from apollo-ios.
Hmmm, I'm just as confused as before. Are you running the latest versions? Do you still get +exec apollo-codegen
without any arguments?
from apollo-ios.
@martijnwalraven yes I am on the latest versions. Actually I am getting ++exec apollo-codegen
(with an extra +
in the beginning)
from apollo-ios.
No idea what the difference is, but I'm also getting xx
now:
Are you running a custom shell environment or Bash version?
from apollo-ios.
@martijnwalraven I am running zsh
with oh-my-zsh
on my terminal. I am not sure whether this is an issue though since on the "Build Phase" the script is directed to use /bin/sh
as the shell.
from apollo-ios.
Yeah, that shouldn't be an issue. I'm also running zsh
with oh-my-zsh
.
I don't really know how to debug this. Shell scripts aren't one of my strongest points :)
Have you had a look at check-and-run-apollo-codegen.sh
to see if anything jumps out to you?
from apollo-ios.
I'm getting the same problem?
Is there any way to solve the problem?
Thanks a lot.
Jing
from apollo-ios.
@jzhw0130: Are you sure it's the same problem? What do the command arguments in the build output look like for you (see above)?
from apollo-ios.
Sure
Only says :
++ exec apollo-codegen
No arguments
Jing
from apollo-ios.
Hi
Also get the same result.
Script as :
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}/Tests/StarWarsAPI
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate '**/*.graphql' --schema schema.json --output API.swift
Jing
from apollo-ios.
@jzhw0130: Why does it say cd ${SRCROOT}/Tests/StarWarsAPI
? That doesn't seem right, because you probably don't want to generate files for the test queries. You probably want to replace this with cd "${SRCROOT}/${TARGET_NAME}"
.
from apollo-ios.
Yes I just do a test with the test queries. If it does work, I will do my query.
But now, demo does not work.
from apollo-ios.
from apollo-ios.
@jzhw0130: I have no idea how to debug this, because I can't reproduce it and I've only heard it happen with you and @attheodo so far. Is there anything about your setup that might explain this? OS X version, the shell you use, how you installed Node?
from apollo-ios.
@martijnwalraven
Thanks for your patience.
OS: mac os 10.11.6
Node: v7.10.0
shell: bash
apollo-codegen --version: 0.10.13
npm -v : 4.2.0
Just download the frontage demo from : https://github.com/apollographql/frontpage-ios-app
Then nothing change, just build to get the API.swift.
Jing
from apollo-ios.
As @attheodo said, I have to do the process of 'apollo-codegen' on the Terminal as follows:
apollo-codegen generate *.graphql *.graphql --schema schema.json --output API.swift
Although it is a little trouble, but it works.
Jing
from apollo-ios.
@jzhw0130: I'd really like to understand what is going on. But I just tried it again, cloning a fresh copy of frontpage-ios-app
and reinstalling apollo-codegen
0.10.3 from npm, and everything seems to work for me.
For some reason, the arguments passed to $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh
are not passed on to apollo-codegen
in certain environments. We execute it with exec apollo-codegen "$@"
, which seems pretty standard, so I don't know why that doesn't work in your case.
from apollo-ios.
Sorry
I'm not familiar with shell script, can not get the problem...
from apollo-ios.
One more detail:
check-and-run-apollo-codegen.sh change as:
Print commands before executing them (useful for troubleshooting)
set -x
echo $0
echo $1
echo $@
echo $*
Result:
Showing All Messages
Showing All Messages
++ echo /Users/jing/Library/Developer/Xcode/DerivedData/FrontPage-bmlzfqrnzbhvyqacptgxyziypyqq/Build/Products/Debug-iphonesimulator/Apollo.framework/check-and-run-apollo-codegen.sh
/Users/jing/Library/Developer/Xcode/DerivedData/FrontPage-bmlzfqrnzbhvyqacptgxyziypyqq/Build/Products/Debug-iphonesimulator/Apollo.framework/check-and-run-apollo-codegen.sh
++ echo
++ echo
++ echo
Only get the first parameter...
from apollo-ios.
@jzhw0130: Hmmm, so the parameters aren't even passed to check-and-run-apollo-codegen.sh
.
Could you try echoing $APOLLO_FRAMEWORK_PATH
from the build script phase?
from apollo-ios.
@martijnwalraven
Input:
echo $0
echo $1
echo $@
echo $*
echo $APOLLO_FRAMEWORK_PATH
Output:
Showing All Messages
++ echo /Users/jing/Library/Developer/Xcode/DerivedData/FrontPage-bmlzfqrnzbhvyqacptgxyziypyqq/Build/Products/Debug-iphonesimulator/Apollo.framework/check-and-run-apollo-codegen.sh
/Users/jing/Library/Developer/Xcode/DerivedData/FrontPage-bmlzfqrnzbhvyqacptgxyziypyqq/Build/Products/Debug-iphonesimulator/Apollo.framework/check-and-run-apollo-codegen.sh
++ echo
++ echo
++ echo
++ echo
from apollo-ios.
@jzhw0130: I meant putting echo $APOLLO_FRAMEWORK_PATH
in the build script phase in Xcode, not check-and-run-apollo-codegen.sh
.
from apollo-ios.
@martijnwalraven
Sorry
cd ${SRCROOT}/${TARGET_NAME}
echo $APOLLO_FRAMEWORK_PATH
Showing All Messages
/Users/jing/Library/Developer/Xcode/DerivedData/FrontPage-bmlzfqrnzbhvyqacptgxyziypyqq/Build/Products/Debug-iphonesimulator/Apollo.framework
++ echo /Users/jing/Library/Developer/Xcode/DerivedData/FrontPage-bmlzfqrnzbhvyqacptgxyziypyqq/Build/Products/Debug-iphonesimulator/Apollo.framework/check-and-run-apollo-codegen.sh
/Users/jing/Library/Developer/Xcode/DerivedData/FrontPage-bmlzfqrnzbhvyqacptgxyziypyqq/Build/Products/Debug-iphonesimulator/Apollo.framework/check-and-run-apollo-codegen.sh
++ echo
++ echo
++ echo
from apollo-ios.
Getting the same issue:
++ exec apollo-codegen
No API.swift generated.
If I do it manually with apollo-codegen generate *.graphql --schema schema.json --output API.swift
, the API.swift is generated.
from apollo-ios.
I'm getting a similar issue. I've installed apollo-codegen using npm install -g apollo-codegen
and it seems to install correctly.
But when I try to build my project (with the correct build run script), I get error: Can't find apollo-codegen command; make sure to run 'npm install -g apollo-codegen' first.
I'm running:
Xcode 8.3.3
node v8.4.0
npm 5.3.0
Also using oh-my-zsh
Have you found the solution to this?
from apollo-ios.
with the following versions
- Apollo (0.8.0):
- Apollo/Core (= 0.8.0)
- Apollo/Core (0.8.0)
I had to change
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh ...
to:
$APOLLO_FRAMEWORK_PATH/Resources/check-and-run-apollo-codegen.sh ...
from apollo-ios.
@i-Roma
@NiltiakSivad
@shelldonhu
Still stuck on this. Can you please provide a little more explanation on how to fix this?
Is it best to create a blank .graphql file in a text editor then move this into the project directory in Finder?
Which folder does ${SRCROOT}/${TARGET_NAME}. relate to?
Thanks
from apollo-ios.
@Edwardharpham, with the blank .graphql file you probably will get error like
Syntax Error: Unexpected EOF
Just create an empty file in your left navigation panel in Xcode with .graphql extension, and add in the file query or mutation that contains your schema.json.
Also, you can check my answer where I describe how to avoid this problem. Of course with words of gratitude to @NiltiakSivad :)
from apollo-ios.
@i-Roma , I am also still stuck on this, how did you add in the file query in the graphql file? Could you maybe provide som screenshots of how you did this?
Thanks:)
from apollo-ios.
Ok, I was not alone to struggle with this issue. I'm not sure who is in charge to maintain apollo documentation but it seems like the installation order is not properly align. Can anyone have a full steps to fix this issue?
from apollo-ios.
I don't know if it is relevant, but I had to change the button line of my script to
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate *.graphql --schema schema.json --output API.swift
That made everything run for me.
Edit:
I am actually not generating an API.swift with the above, but can make it work manually as others have pointed out above with apollo-codegen generate *.graphql --schema schema.json --output API.swift
Edit 2:
With pod 0.9.1 it works with the script in the installation guide, but I needed to make the reference to the file manually
from apollo-ios.
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries=\"$(find . -name '*.graphql')\" --schema=schema.json API.swift
from apollo-ios.
I've recently updated the setup instructions for the build phase setup here - I'm going to close this out since that should solve a fair number of these issues. Please open a new issue if you're still encountering problems. Thank you!
from apollo-ios.
Related Issues (20)
- Xcode 15 Beta "Expression" name collision HOT 4
- ApolloSQLite doesn't compile on Xcode 16 due to `Expression` symbol clash with new `Foundation.Expression` HOT 3
- Request to clear derived data when switch from build for test to build for run HOT 5
- Adding in mocks is causing our tests to fail. HOT 3
- [Xcode 16] Mutating property of a fragment causes compile time error HOT 2
- SQLite: Ability to change journal mode HOT 6
- Getting the error "Module ApolloAPI was not compiled for testing" while compiling swift package in "Release" mode in apollo v1.7.0. HOT 3
- Package Resolution Failed: Invalid Manifest when installing a library with an Apollo dependency HOT 2
- Cannot find 'LaunchListQuery' in scope HOT 2
- `.editorconfig` HOT 2
- How to Implement GraphQLQueryPager in Apollo iOS for Pagination? HOT 2
- docs: Update Pagination docs to callout separate package
- Uploading files with apollo HOT 1
- Crash Thread 1: Fatal error: No data found for task 1, cannot append received data HOT 4
- Use ApolloClient with swift-corelibs-foundation 5.10.1 HOT 2
- RFC: 2.0 API Changes - Swift Concurrency HOT 5
- Add support for local cache mutations HOT 2
- Pagination: Errors on initial page not reported HOT 3
- CacheKeyInfo with a numeric jsonValue of `1` returns nil HOT 1
- Type 'Operation' has no member 'deferredSelectionSetType' in IncrementalGraphQLResponse HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-ios.