Having tried SwiftUI for some of my mobile development projects, I’d like to share some thoughts about this young but dynamic tool. It’s very similar to other players on the market like React Native, Xamarin or Flutter. So let me compare it with the latter one from an iOS developer's point of view. Which tool is better for creating and developing mobile apps? What are pros and cons of SwiftUI and Flutter?
1. SwiftUI's and Flutter's development speed
SwiftUI is a relatively young element of iOS development. It has been introduced this year by Apple and just starts growing. I suppose SwiftUI will dynamically replace
XIBs. Mainly because it's much faster than those tools, and simply generates fewer problems. But firstly, much faster.
From an iOS developer's perspective Flutter is very similar to SwiftUI, especially in terms of development speed. In both SwiftUI and Flutter, developers don’t need to reload an app just to show the latest changes. The hot reload feature is a real game changer. And because it's available in both frameworks, there is no big difference if you write your code in Android Studio using Flutter or in Xcode, using SwiftUI. In both cases, reloading apps in Simulator comes really fast.
While SwiftUI uses a built-in Xcode builder, called Automatic preview assistant, Android Studio reloads apps in Simulator. In my opinion, while the SwiftUI option is little bit faster, it’s way better to see an app in Simulator - not just its current
view as in SwiftUI. On the other hand, in Flutter you can’t make real time changes in layout - as in SwiftUI’s preview.
If you’re curious what are the differences between creating views in Flutter and SwiftUI, I recommend checking out an experiment in which a SwiftUI sample app was recreated with Flutter at WWDC 2019. The results were very similar, but thanks to relative maturity of Flutter writing code is a little bit faster.
On the other hand, SwiftUI will be undoubtedly easier for an iOS developer than using Dart, the language created by Google and upon which Flutter is based. In my opinion, SwiftUI is way cleaner than Flutter, mainly because it was designed only for iOS devices. Flutter, created to handle both iOS and Android, needs more code to achieve the same goals.
Flutter also allows more ways to write views with
ListViews. In SwiftUI, at least for now, we have just Lists and that’s all (consider lack of
As I metioned, Flutter is more mature that SwiftUI. This can be observed (in matter of building of views) in allowing developers to use many ways to achieve the same goals. On the other hand, SwiftUI has much fewer solutions for building views right now. This surely will change in the future, but for now if you want to build more complex applications, better way is to use Flutter (or stay with Storyboards in Xcode - but this is just another story). All in all, being a tool created for cross platform development, Flutter will always have more ways to build complex views.
From my perspective, watching the growth of SwiftUI and Flutter is a thrilling experience. Developed by Apple, SwiftUI is for sure the name of iOS development's future. Also Flutter, supported by Google, is a more and more interesting tool for cross platform mobile apps. I suppose it will become a primary tool for such dealings, with a chance of overgrowing Xamarin or even React Native. I surely will have an eye on both!