Chapter 1 — Introduction & course overview

What "networking" actually means in an app

  • build a request — a URL, an HTTP method, headers (who you are, what format you send), and maybe a
  • hand it to the operating system, which opens a connection, negotiates TLS (encryption), sends the
  • receive a response — a status code, headers, and a body (usually JSON);
  • decode that body into Swift types, or handle an error;
  • and reflect the outcome in your UI — a spinner while waiting, content on success, a message on
flowchart LR App["Your app"] -->|"URLRequest"| URLSession URLSession -->|"TLS + TCP"| Server[(Server)] Server -->|"status + headers + body"| URLSession URLSession -->|"Data + URLResponse"| App App -->|"decode → model → UI"| UI[Screen]

Why not just use Alamofire (or another framework)?

The topics we'll cover — and why each matters

The app: Chirp for iOS

flowchart LR Login["Login / Register"] -->|"auth requests"| Feed Feed["Feed (paginated)"] -->|"tap"| Detail["Post detail
(likes, comments)"] Feed --> Compose["Compose post"] Feed --> Profile["Profile
(avatar upload)"] Feed --> Notif["Notifications
(WebSocket)"]

The stack and the ground rules

  • Swift 6, iOS 17+, SwiftUI, @Observable, async/await. Modern, structured concurrency
  • Plain URLSession, no HTTP framework. We add exactly two third-party SDKs, and only in Chapter
  • Layered architecture. Views → view models → repositories → APIClientURLSession. Each layer
  • Testable by construction. Because the client is a seam we control, we test it against stubbed

What "done" looks like

  • Describe every backend call as a typed Endpoint and run it through one APIClient.
  • Drive every screen with a clean loading / loaded / error state.
  • Log in, store JWT access + refresh tokens in the Keychain, and refresh them automatically
  • Run requests through an interceptor chain that injects auth, retries transient failures,
  • Paginate the feed with infinite scroll, upload avatars, download and cache images, and
  • Report itself to Sentry and DataDog, collect URLSessionTaskMetrics, and pin its

Mental model to take away

  • The URL Loading System (URLSession) can do everything a production app needs; the work is giving
  • We build on raw URLSession, no framework, so nothing is hidden — you'll understand what any tool
  • The app is Chirp for iOS, the client to the Chirp API; each screen carries one networking topic,
  • The payoff is a networking layer that's reusable, testable, secure, and observable — the 95% past