Don’t Give Up on SwiftUI Previews!

SwiftUI Previews have ruined UIKit for me…

Previews are a life-changer!

Every iOS developer has a love-hate relationship with SwiftUI. Sure, it simplifies UI programming, offers cool features like Widgets and Live Activities exclusive to SwiftUI, but its glorious bugs and paradigm shift away from imperative UIKit can make even seasoned developers hesitate.

Honestly, I felt exactly the same. I figured sticking with UIKit would be fine. But reality struck when my company took on a SwiftUI project, forcing me to dive headfirst.


After about a month of struggle, I gradually found my development speed catching up to, and even surpassing, my previous pace with UIKit.

There are several reasons for this, but the biggest one? Previews.

Previews? Didn’t everyone try those when they started, only to ditch them later?

Yes and no. When I first started iOS development, I was amazed by SwiftUI’s ability to render UI directly on the Canvas. But as projects grew larger, Previews became painfully slow… until I couldn’t stand it anymore. So, I gave up on Previews and went back to the familiar cycle of build-run-debug-repeat.

However, after some encouragement from Speaker 13 at iPlayground last year, combined with the increasing UI complexity in my own projects, I decided to give Previews another shot. And wow, was I reminded of how incredibly convenient and awesome they are! Especially when dealing with multiple UI states.

For example:

Let’s say I’m building a to-do list app, where each task is displayed as an item like this:

Now, suppose I need to add a tag next to the title to show four different progress states: Canceled / Completed / To Do / In Progress. How would I approach this?

With UIKit, I’d previously have to build the app repeatedly, checking each state manually. But in SwiftUI, I can quickly define all states right in Preview:

// Preview the four different states at once
#Preview {
    VStack {
        ContentView(
            model: .init(
                date: "2025/01/01",
                title: "Buy Flowers",
                tagType: .cancel)
        )
        
        ContentView(
            model: .init(
                date: "2025/02/01",
                title: "Pick Oranges",
                tagType: .complete)
        )
        
        ContentView(
            model: .init(
                date: "2025/03/01",
                title: "Fly in the Sky",
                tagType: .waitingToDo)
        )
        
        ContentView(
            model: .init(
                date: "2025/04/01",
                title: "Go to Disneyland",
                tagType: .doing)
        )
    }
}

Furthermore, since SwiftUI views re-render based on state changes, we can also easily test UI interactions!

For example, marking a task complete changes its tag and icon. Preview effortlessly demonstrates this interaction without tedious builds.

Now imagine tackling all this without Previews: as your project grows more complex with multiple UI states, you’ll build and run your app more frequently, and build times will inevitably skyrocket!

So, for all you developers who’ve turned off Previews: turn them back on! You might discover a whole new world of development efficiency.

Feel free to reach out with any thoughts! Bye for now~