Creating a Tube Status App in SwiftUI

A super simple look at how to work with APIs and SwiftUI

Fred Gray
The Startup

--

London Underground train blurred as it moves past platform
Photo by Dan Roizer on Unsplash

Full disclosure — I’m not the best iOS developer, or programmer in general. I’d scarcley got my head around UIKit and the delegate pattern for handling data received from APIs before *boom* I open up Xcode after a break and all of a sudden there’s a view struct staring back at me — not a trusty viewDidLoad method in sight! That’s how I discovered SwiftUI. At first, I was immensely confused — the paradigm shift from the imperative UIKit to the declarative SwiftUI is a real head-scratcher if you’ve still at the level where closures freak you out. But I quickly saw how easy and intuitive it was to create really stunning, flexible user interfaces, and that convinced me it was well worth sticking with it, especially after the enhancements introduced SwiftUI 2 earlier this year.

With that in mind, we’re going to use Transport for London’s API to get information on the staus of London Underground (and DLR) lines. It’s a powerful, well-documented API that can give us all sorts of data about transport in London and beyond. Our app will be super, super simple — it will display all of Tube lines, and their current status, each line presented as a tile:

--

--

Fred Gray
The Startup

One part experience, nine parts curiosity: history, iOS development, design, and whatever else ends up floating my boat.