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).<p>Many on my team push for React Native but I believe native code is the smarter choice.<p>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?<p>Thanks a lot for your insights.
Reference: I used SwiftUI quite a bit at work but much more on my side project which is an iPad / Catalyst app [1].<p>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.<p>- 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 <i>can</i> 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.<p>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.<p>[1]: <a href="https://hyperdeck.io" rel="nofollow">https://hyperdeck.io</a>