I've said it before, but wow is SwiftUI good. I just finished migrating a massive, super complicated UIKit view hierarchy. I had estimated that the rebuild would take around 2 weeks to finish...it took 1.5 days.

🤯

And the best part is that the result has way better support for Dynamic Type and VoiceOver...and is like 20% of the lines of code.

@_Davidsmith Yeah, at Booksy, which has a large app written fully in SwiftUI since iOS 13, we spend 90% of time on business logic, because writing views is such a breeze.
@_Davidsmith after three years of writing in SwiftUI I can’t imagine going back to UIKit.

@_Davidsmith I'm finding it super productive to build UI as well!

What still gets me is the little things I cannot do properly, like controlling the status bar color of the view controller without some big hack.

But the speed at that we can make a good UI is impressive!

@rafaelks I've long ago given up on fighting those little battles against it, if SwiftUI can't do it then I'll just refactor my design to accommodate that and move it. For the early years I'd fight and fight, but usually I can find an approach now that is viable and doesn't involve pulling my hair out.
@_Davidsmith Have you ever written/talked anywhere about your general architecture patten for SwiftUI based apps? I’m assuming you’re doing something more lightweight than something like TCA?
@charliemchapman I'm not sure I've documented it specifically. I don't know what TCA is, but yeah, I'm almost certainly doing it in a very lightweight way. I start with top level screen, and then just keep breaking it down into smaller and smaller parts until I reach the leaf view...then combine them all together on the way up. Which works for me 🤷🏻‍♂️

@_Davidsmith @charliemchapman I think that actually is a pretty great approach.

We put a lot of emphasis when building the framework in allowing developers to have small and lightweight pieces that can be composed together.

@lucabernardi @_Davidsmith So far that’s what I’ve been doing, but the piece I feel like I’m missing is the equivalent to a Coordinator in UIKit land that handles the navigation logic. And maybe I just don't need that? But it makes me feel a little queasy with it all living directly in the views, haha

@charliemchapman @lucabernardi @_Davidsmith I use a single ObservableObject to track navigation state. Call it a "ViewModel" or a "Coordinator" or whatever. Stick it in an .environmentObject and inject it wherever you need it.

So views operate on the navigation object directly, but it still lives in a single place that can have its own logic.

@charliemchapman @lucabernardi @_Davidsmith Removing that navigation logic from views makes them more reusable which may be important depending on the view or the app.

I haven’t tried this technique but I read about someone creating container views just for that navigation logic and then have them wrap other views that display things. Sounds odd but could work for some people/apps.

@charliemchapman Since you mentioned TCA, I'm curious if you've seen Point-Free's video series on navigation in SwiftUI? If not, I highly recommend it! The big takeaway for me was that navigation isn't a separate concern of logic in a SwiftUI application, it's just... more state! All we have to provide as app developers are bindings to state that can drive that navigation and the framework handles the rest.
@jessetipton I haven’t, I'll have to check that out. When I was diving into TCA a whie back I found it to be much heavier than I prefer (especially for personal stuff) but I’d be curious to hear that perspective

@charliemchapman @jessetipton For what it's worth, the navigation stuff Jesse is referring to is not TCA. It's just a few tools that make vanilla SwiftUI navigation easier to model precisely, using enums:

http://github.com/pointfreeco/swiftui-navigation

There are lots of examples in that repo, including a port of Apple's "Scrumdinger" app from 2021: https://github.com/pointfreeco/swiftui-navigation/tree/main/Examples/Standups

GitHub - pointfreeco/swiftui-navigation: Tools for making SwiftUI navigation simpler, more ergonomic and more precise.

Tools for making SwiftUI navigation simpler, more ergonomic and more precise. - GitHub - pointfreeco/swiftui-navigation: Tools for making SwiftUI navigation simpler, more ergonomic and more precise.

GitHub
@pointfreeco thanks, I’ll definitely check that out!
@jessetipton @charliemchapman this is my dream, but is it buggy or robust yet? last time I tried state-driven nav with SwiftUI it was super buggy and frustrating, and only continued to hear bad things since
@charliemchapman @lucabernardi @_Davidsmith Ugh, I’ll write a blog post. 😉 I’ve got a pattern that’s served me well (basically a global logic manager for app-wide things, like navigation coordinating, plus view models at the view level).

@thillsman @charliemchapman @lucabernardi @_Davidsmith interested to see your approach.

Have you checked how the #IceCubesApp (source code on GitHub) handles this navigation topic using a “router”? https://github.com/Dimillian/IceCubesApp/blob/main/Packages/Env/Sources/Env/Routeur.swift and AppRouteur: https://github.com/Dimillian/IceCubesApp/blob/0260f85d58b366ad3a13c5f158f55dc902c96734/IceCubesApp/App/AppRouteur.swift

Would love feedback on this!

IceCubesApp/Routeur.swift at main · Dimillian/IceCubesApp

A SwiftUI Mastodon client. Contribute to Dimillian/IceCubesApp development by creating an account on GitHub.

GitHub
@alpennec ok now this could be super helpful! 👀
@_Davidsmith I was so happy with my VoiceOver and dynamic type improvements when I rewrote my first app in SwiftUI.
@_Davidsmith Nice!! So what are you going to do with the rest of your 12.5 days now free?
@_Davidsmith …with the additional benefits of having reusable views for widgets!
@_Davidsmith I'm at this point where I use UIKit or AppKit only if I really need to. There are still many shortcomings in SwiftUI but it's much better than 2 years ago.
@_Davidsmith Part of that is how incredibly outdated UI-Kit is though. I came to SwiftUI from React, and that comparison is alot more mixed.
@_Davidsmith amazing! I wish you patience as UX tweaks things to their liking ;)
@_Davidsmith as someone who has been keeping an eye on Swift UI from a distance, I’m excited to see how much it has matured!