Unable to build tutorial iOS app

Hi, I am unable to get the tutorial app working. I am stuck on the part where we run a build script to download the sample json schema. Here is my script which I got following the iOS tutorial.

# Don't run this during index builds
if [ $ACTION = "indexbuild" ]; then exit 0; fi

# Go to the build root and search up the chain to find the Derived Data Path where the source packages are checked out.

while ! [ -d "${DERIVED_DATA_CANDIDATE}/SourcePackages" ]; do
  if [ "${DERIVED_DATA_CANDIDATE}" = / ]; then
    echo >&2 "error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'"
    exit 1


# Grab a reference to the directory where scripts are checked out

if [ -z "${SCRIPT_PATH}" ]; then
    echo >&2 "error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project."
    exit 1

#"${SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="schema.json" API.swift
"${SCRIPT_PATH}"/run-bundled-codegen.sh schema:download --endpoint="https://apollo-fullstack-tutorial.herokuapp.com/"

I am getting this error here

Loading Apollo Project [started]
Loading Apollo Project [completed]
Saving schema to schema.json [started]
Saving schema to schema.json [failed]
→ ServerParseError: Unexpected token T in JSON at position 0
Error: ServerParseError: Unexpected token T in JSON at position 0
Command PhaseScriptExecution failed with a nonzero exit code

How do I resolve this?

Hm, looks like there’s an error downloading the schema, since that “unexpected token T” indicates that JSON isn’t being returned from that endpoint.

Two things to check:

  • What version of the iOS SDK are you using? There’s been an issue with SPM where it doesn’t correctly select the most recent version in 0.x versions, and it pulls 0.9.x instead of 0.50.x.
  • If you’re not using a more recent version of the SDK, my other thought is that some updates we recently made to a couple things might have messed with the URL. Could you try https://apollo-fullstack-tutorial.herokuapp.com/graphql and let us know if that works?
1 Like

I’m using Apollo 0.50.0. Xcode 13.1 (13A1030d) if that matters.

I tried changing the url to https://apollo-fullstack-tutorial.herokuapp.com/graphql, this fixed it! Thanks. The tutorial has it as the incorrect url: https://apollo-fullstack-tutorial.herokuapp.com/

Thanks for posting! We recently updated the example server’s URL and forgot to update the tutorial accordingly :grimacing: This has now been fixed.

1 Like