Hacker News new | ask | show | jobs
Ask HN: How is Swift UI performing for you in late 2021?
6 points by blueslurpee 1747 days ago
My team and I need to build a mobile application which will involve complex views and animations, and long term down the road access to important hardware on the phone. (Think new LiDaR scanner on iPhone 12).

Many on my team push for React Native but I believe native code is the smarter choice.

People using SwiftUI what has your experience been like? Threads from late 2020 and early 2021 mention that the framework is very enjoyable but needs to mature. What has your experience been like? Have you found it simple to build in UIKit code where necessary?

Thanks a lot for your insights.

1 comments

Reference: I used SwiftUI quite a bit at work but much more on my side project which is an iPad / Catalyst app [1].

Since my use case (layout of complex slides) differs from the _standard_ uses of SwiftUI (nested lists or collections of items and detail views), I can say less about the viability of building these nested lists. However I do have a lot of feedback about SwiftUI evolution in general.

- Error reporting and build times have much improved and are mostly ok nowadays - Previews still don’t work well for a reasonably sized app, except if you go out of your way to keep the dependencies small and have the UI be its own framework (which is good advice in general but not always easily possible) - SwiftUI’s layout system is less flexible than what UIKit can do. You can hoist UIKit views in SwiftUI but there’re issues where the UIKit View cannot know the available size that it should operate it (e.g. there’s no SwiftUI equivalent to ‘sizeThatFits:’) you’re still a bit limited here (for very complex responsive layouts). - Instead of placing UIKit Views in SwiftUI what I’m doing is placing SwiftUI Views in UIKit. This works well and gives me more flexibility. - SwiftUI has a lot of benefits that make it a joy to work with. Easy animations, dark / light mode, very fast layout, great selection of views/widgets. - There’re still weird layout bugs from time to time. In comparison to UIKit there’s usually no way to engineer around them. This is much more pervasive on macOS though. - For certain use cases, getting good performance is a bit tricky. However, a similar usecase with UIKit would also be tricky. Sometimes a really smooth UI takes a bit more dedication.

The major downside, as of today (for me) is that SwiftUI is not downwards compatible. The newest version (SwiftUI 3) will only work on the newest iOS releases but adds criticial features and fixes important bugs. If your product is supposed to also run on older iOS devices (say, down to iOS 13), stay away from SwiftUI as the old version has a lot of weird issues and bugs.

[1]: https://hyperdeck.io

Great response and awesome side project, thanks a lot!

Do you have any thoughts on the “native vs. React native” question?

Like many things in life I think it depends. React Native promises a 2x improvement because instead of developing 2 apps you develop one. However, there's obviously additional overhead. Some parts still need to be implemented natively or via plugins, some parts need to look different dependent on the native OS, some new tech might not be incorporated yet so you need to work around these issues. Also, I've heard that the build system is kind of brittle (e.g. projects suddenly failing to compile). So in reality you're not gaining 2x but maybe something like 1.5x. Another upside of React Native is that you can hire Javascript developers instead of native ones (who are harder to find, I think). However they will still need to know about the underlying platform from time to time. I also found that it makes quite a difference in quality whether the developers actually use the underlying OS (iOS / Android) because they will complain if a PO or UX comes up with a solution that goes against the Platforms HIG.

Given these issues, the real benefit of React Native is bound to the size and scope of the app. I've worked on a social network app with 500+ screens and here, I think, React Native would be the better solution. A 1.5x win is still huge if you implement 500 screens twice. On the other hand, if we're talking ~25 screens and the moat of the app lies in complex backend tech, I think you'd fare better going native (SwiftUI / Jetpack Compose).