The last Apple WWDC conference was very rich, and certainly the most exciting announcement was for us SwiftUI. A new Framework (Toolbox for non-English speakers) to create interfaces on all Apple platforms... Yes all!
After many years of relying on XCode and its interface editor. Apple seems to have listened to its developers and made back machine. Before we could not make an application compatible with iOS, MacOs, TvOS without making 3 or more different applications. This is the first point pushed by SwiftUI, 1 code for the whole Apple environment!
Farewell to 1978000 Xcode options
Apple had long relied on a visual interface editor to design its applications. Yes, but here it is, the years go by, and they added (a lot) of possibilities. So much that it quickly becomes chaotic. It's visual, but to develop complex interfaces it's impractical.
As a reminder here is what the design of an interface on Xcode looks like today:
Creating an iOS or other application without Xcode is suicidal. The link between your code and the interface is sometimes complex enough for not much.
SwiftUI to the rescue
Apple has hit hard, and as usual does not hesitate to totally change its way of thinking. Indeed, SwiftUI is entirely based on code. No interface editor, just code.
No graphical editor, but why is it simpler?
As I told you before, the Xcode editor becomes more and more complicated, but not only. A much awaited feature of SwiftUI: the Hot Reload. Being able to change the graphical aspect of our application while coding without having to restart the application!
Having the graphical interface as well as the logic in the code brings real flexibility and simplicity for developers. Apple is not the only one to be aware of this. The components are much more easily reusable, animations are simplified...
Without going into detail here, it is much easier to create an application without having to dispatch a graphical interface in X files (CF: Android and its Xml files for customs components). It's a bit like reading a book in English and then having a part in French and then in German. Even if you can read all three languages, it's quite complicated to switch from one to the other every 2 minutes, and well for development it's the same thing.
In the line of Flutter
Flutter for those who don't know it yet, it's Google's new open source project to build native iOS and Android applications with one and the same code.
The way of thinking is essentially the same, we encapsulate the interface bricks into each other to build our GUI.
For those who are interested, here is an excellent article comparing Flutter programming with SwiftUI.
SwiftUI is doing a very big tour de force, completely changing a way of thinking for a giant like Apple is a huge challenge. The bet seems to be successful as the feedback from the community is good.
A change that many developers have been waiting for a long time that should facilitate development on the whole Apple environment.