Member-only story

The Simple Life(cycle) of a SwiftUI View in 2025

Revisiting an Elementary Topic… Half a Decade Later

--

When SwiftUI was first announced in 2019, we developers were trying to understand the new world from our old, UIKit one. And anyone who’s worked with UIKit knows that understanding the UI lifecycle is a crucial must.

That’s why one of my first articles was a comparison of what SwiftUI offered against the UIKit cycle we knew. An important quote I included in that article came from Paul Hudson who concluded that:

Your SwiftUI code will be maybe 10–20% of what your UIKit code was — almost all of it disappears because we no longer repeat ourselves, no longer need to handle so many lifecycle methods, and more. — Paul Hudson, Hacking With Swift

To this day, I still receive comments on that article and private messages citing it by those just entering (or still trying to figure out) SwiftUI.

Almost 6 years later, I’m here to say that the SwiftUI Lifecycle is worth revisiting, expanding upon, and without focusing on comparisons. The reasons being:

  1. Apple has since defined an entire App Lifecycle around SwiftUI
  2. The Lifecycle of a View has gained capabilities
  3. UIKit may still be relevant to your needs, but Apple is no longer pushing it as the gold standard. As time goes on, UIKit will most likely become the exception/edge case in modern repos

Bold statements, but sometimes we need to read the wind and sea the best we can as we discern how best to approach the future of development.

The View Lifecycle

So, without further ado, let’s start with the beginning (that’s a very good place to start, after all).

init

The first stop is the initializer of a View. This is our chance to setup all our properties (run their respective initializers, as well), and do any other light-weight operations before we start rendering our View.

We get init because View is a struct. It is true that a struct gets memberwise initializersfor free (initializers generated based on the defined properties of a struct). But if there’s anything else that needs to…

--

--

Danny Bolella
Danny Bolella

Written by Danny Bolella

Captain SwiftUI | Software Developer Lead iOS | Writer | Reader | Husband/Father

No responses yet

Write a response