1. Course intro and setup
10m

Overview

Welcome! In this first course in Odyssey's Swift series, we'll enable an app to communicate with a by adding the SDK. We'll start by downloading a schema, running codegen, and writing queries and . By the end of the series, you'll be equipped to handle errors, pagination, authentication, and !

In this lesson, we will:

  • Learn about what we're building, and the technologies that help us build it
  • Set up our project environment

What is GraphQL?

Let's begin with the most important question of the course. What is GraphQL?

is the developer-friendly language for the modern web. It transforms how apps fetch data from an API, enabling you to get exactly what you need with a single query—instead of wrangling responses from a patchwork of REST endpoints.

With a strongly typed schema at its core, helps you define relationships between data across any number of systems, empowering you to focus on what your data can do instead of where it's stored.

Throughout this course, we'll learn how to integrate with our frontend app, making it easier to serve up data to our users and build faster than ever before. Get ready to roll up your sleeves, write some code, test your understanding, and build something cool!

A diagram showing GraphQL as the contact point between multiple clients and the complex architecture of a modern backend

What we're building

We're going to build an app that lets us "book a seat" on any of the rockets that have been sent into space by SpaceX. We'll connect to a that's hosted on Heroku and is powered by Apollo Server.

If you're curious about how to build your own , check out Odyssey's backend courses, available in a variety of programming languages.

Prerequisites

To follow along...

  • You should be familiar with basic programming concepts in Swift. (We assume some prior experience with iOS development.)
  • You'll need a Mac as well as Xcode (v15.4), with the iOS component installed
  • Bonus: The course is built using SwiftUI. You won't need any prior experience with SwiftUI, but we'll use it to illustrate how to use the SDK.

Clone the repository

In the directory of your choice with your preferred terminal, clone the app's starter repository:

git clone https://github.com/apollographql/apollo-ios-odyssey

We'll work out of the starter directory.

Note: If you get stuck at any time during the course, feel free to check out the final directory for some help: it contains the completed app.

Task!

Project setup

Navigate to the apollo-ios-odyssey directory, and open up the starter folder in Xcode. Then, locate the RocketReserver.xcodeproj file and open it.

Folder structure for opening project, focused on Rocket Reserver

When the project opens, Swift Package Manager (SPM) will resolve some dependencies that you'll be using later in the project that are already set up:

If you build and run the project you should see a list with placeholder data:

Starting app state

Next let's add Apollo as a dependency.

Adding the Apollo iOS SDK

Go to File > Add Package Dependencies.... The Add Package dialog appears, by default with Apple packages.

The Xcode add package dialog, highlighting the search bar

In the upper right-hand corner, paste the following link to the repo into the search bar:

https://github.com/apollographql/apollo-ios

The Xcode add package dialog, updated to search for the Apollo iOS package

Select the latest minor version

Xcode will then show you the apollo-ios package and allow you to select a version in the right-hand panel. Select Up to Next Minor from the Version dropdown (At the time of writing, the current minor version is 1.15.x, note that minor breaking changes can occur between minor releases):

Highlighting Up to Next Minor Version in the dialog window for Apollo iOS

Task!

List the targets

Click Add Package. Once SPM is done checking out the package, a list of framework targets included in the library appears. For this tutorial, enable both Apollo and ApolloWebSocket packages, updating the Add to Target dropdown for each so it says "RocketReserver":

Select the first and last targets

Note: Do NOT select the Apollo-Dynamic target; this is only for use for projects linking to our library dynamically. Most projects, including this one, will not need to do this.

Finish up

Click Add Package. SPM fetches your dependencies. When it completes, you can see them in the project navigator:

The project's list of update dependencies

Note: Because SPM has not yet implemented Target-Based Dependency Resolution, you'll see the SQLite dependency even though you didn't select ApolloSQLite, the target which depends on it.

Task!

Up next

Your project should now be ready to use the SDK. Next, we'll explore the API we'll connect to our project.

Next

Share your questions and comments about this lesson

This course is currently in

beta
. Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.