Giter Site home page Giter Site logo

Comments (48)

NiltiakSivad avatar NiltiakSivad commented on July 23, 2024 15

I experienced multiple errors while attempting to get the auto generation working. Including the following:

  1. 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.
  1. Afterwards, I received an error saying that Apollo.framework does not support the latest version of apollo-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.
  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.

shelldonhu avatar shelldonhu commented on July 23, 2024 6

It can be built successfully when I firstly create an empty .graphql file on ${SRCROOT}/${TARGET_NAME}.

from apollo-ios.

i-Roma avatar i-Roma commented on July 23, 2024 2

@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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024 1

@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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

Could you have a look at the command arguments in the build output (see screen shot)?

screen shot 2016-12-13 at 22 04 40

from apollo-ios.

attheodo avatar attheodo commented on July 23, 2024

@martijnwalraven it only displays +exec apollo-codegen ...weird. Any ideas why is this happening?

from apollo-ios.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

attheodo avatar attheodo commented on July 23, 2024

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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

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.

attheodo avatar attheodo commented on July 23, 2024

Exactly
image
image

from apollo-ios.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

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.

attheodo avatar attheodo commented on July 23, 2024

@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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

attheodo avatar attheodo commented on July 23, 2024

from apollo-ios.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

attheodo avatar attheodo commented on July 23, 2024

@martijnwalraven I still have the same issues in a different project. Any help on how I could debug this?

from apollo-ios.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

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.

attheodo avatar attheodo commented on July 23, 2024

@martijnwalraven yes I am on the latest versions. Actually I am getting ++exec apollo-codegen (with an extra + in the beginning)

from apollo-ios.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

No idea what the difference is, but I'm also getting xx now:
screen shot 2017-01-30 at 15 19 54

Are you running a custom shell environment or Bash version?

from apollo-ios.

attheodo avatar attheodo commented on July 23, 2024

@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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@attheodo @martijnwalraven

I'm getting the same problem?
Is there any way to solve the problem?

Thanks a lot.

Jing

from apollo-ios.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@martijnwalraven

Sure

Only says :
++ exec apollo-codegen

No arguments

Jing

from apollo-ios.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@martijnwalraven

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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@martijnwalraven

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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@martijnwalraven
719d0d18-4f71-49cf-b4d9-d42aa84c9573

from apollo-ios.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@martijnwalraven

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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

Sorry

I'm not familiar with shell script, can not get the problem...

from apollo-ios.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@martijnwalraven

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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@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.

martijnwalraven avatar martijnwalraven commented on July 23, 2024

@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.

jzhw0130 avatar jzhw0130 commented on July 23, 2024

@martijnwalraven
Sorry

cd ${SRCROOT}/${TARGET_NAME}
echo $APOLLO_FRAMEWORK_PATH
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift

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.

pavelshadrin avatar pavelshadrin commented on July 23, 2024

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.

dylanmoo avatar dylanmoo commented on July 23, 2024

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.

yanshiyason avatar yanshiyason commented on July 23, 2024

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.

Edwardharpham avatar Edwardharpham commented on July 23, 2024

@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.

i-Roma avatar i-Roma commented on July 23, 2024

@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.

tormic avatar tormic commented on July 23, 2024

@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.

intoxicated avatar intoxicated commented on July 23, 2024

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.

MrMatten avatar MrMatten commented on July 23, 2024

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.

Cybernization avatar Cybernization commented on July 23, 2024

$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries=\"$(find . -name '*.graphql')\" --schema=schema.json API.swift

from apollo-ios.

designatednerd avatar designatednerd commented on July 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.