#SwiftUI

TIL:

If you have this kind of setup in your SwiftUI app, when are all the views initialized?

For some reason, I thought that OtherView and SettingsView are lazily initialized only when they are opened

But turns out that everything is eagerly initialised right at start

Probably the view body build is only ran when the view is actually displayed, I did not check that part. But initialisation is eager, not lazy, which was unexpected to me, but I guess it makes sense

Further testing the new #iOS18 zoom transition in #SwiftUI. It’s a nice effect and seems to fit nicely in my app. There are a few small bugs though that I need to report, if they persist after the next beta

My beef about today's #Swift adoption at Apple is #SwiftUI. It is a framework that stands against what Swift promised to developers back in the days

- slow
- limited
- runtime crashes if you use the wrong variable type (compile and don't work?)
- unhelpful/misleading compilation diagnostics
- underlying objc frameworks crash and mem leak as it always been
- bad devtools that never improved

How do I prevent #SwiftUI from applying a default animation when changing layout? In other words, what do I do when I *want* abrupt layout changes when state changes?

I want to use a binding with UIViewControllerRepresentable so I need to pass it on to the underlying UIViewController somehow.

I can pass the Binding<> struct itself all the way into the view controller and do stuff like binding.wrappedValue = newThing whenever the view controller wants to tell #SwiftUI about a change from its end.

But how do I observe from the UIViewController so it knows when the bound state value changes on the SwiftUI side (like from a button handler or whatever)?