SwiftUI vs Auto Layout: Pros and Cons of Each Approach
It’s been more than five years from its release date (September 2014) and Apple kept upgrading the language up to Swift 5, sometimes providing good features, sometimes just updating the Xcode IDE and Storyboards improvements.
Then, the SwiftUI language was presented at WWDC 2019 in June and it started becoming popular soon after. It looks like everybody loves SwiftUI.
There are many differences between the two, and even if we don’t have an expiration date for the legacy Auto Layout support, speculations and rumors whisper that SwiftUI will be the future of the UI/UX developing tools in iOS programming.
Auto Layout: From Scratch to Frameworks
The Auto Layout system was conceived by Apple in 2011 and as released to developers and supported in iOS a bit later.
Auto Layout bases its features on a system that is capable of adapting its rendering and appearance using constraints and rules defined by developers.
These rules specify whether or not views should appear larger, should shrink, should shift position coordinates, and more, making all UI components responsive and capable of adapting to screen sizes, resolutions, and different contexts.
SwiftUI: The New, Good, and Bad
The new SwiftUI has been conceived to reorder ideas on UI composition and developing.
If you look around, there are many frameworks, contexts, and technologies where the user interface is more “defined” than “composed”. Think about old XML based UI compositions, or even the HTML/CSS approach it’s basically declarative more than composed by using visual tools.
Declarative interfaces are popular in hybrid apps as almost all of them are developed using Flutter and Ionic.
Flutter uses declarative interfaces such as the old Sencha or the modern React native. In IONIC, the UI is pure HTML/CSS and it’s not much different.
Pros and Cons of Auto Layout and SwiftUI
Auto Layout and Storyboards are well-supported and well-known by developers.
We used Auto Layout so much during the year and we know how to approach the problem.
SwiftUI uses the same approach theoretically (SwiftUI is basically a different way to set Auto Layout-like constraints, it’s not a separate tool or a separate technology), but it’s fresh, new, and sometimes this has a negative impact on the developers’ experience.
SwiftUI looks cool and looks fast to code
Simple interfaces can be coded in zero to little time due to basic components that automatically integrate basic constraints and behaviors.
Storyboards and segues give you an idea of what you’re doing
SwiftUI is basically conceived to design a single view.
Xcode Storyboards is supported by custom views extensions
Xcode Storyboards is supported by custom views extensions via @IBDesignable decorators, SwiftUI needs time to become supported and integrated by custom tools developed by the community.
SwiftUI is supported in iOS 13 only
This is probably the most influential negative aspect, because SwiftUI-based apps won’t be released in enterprise environments for at least one year.
there’s no official announcement about how to eventually make it work on earlier iOS versions. This might not impact B2B apps, but definitively does in B2C and trending apps, regardless of iOS user’s habits on keeping the OS updated.
SwiftUI has real-time preview
Finally, we have a “responsive” way to code our views, something we really wanted in Storyboards and UIKit, where previews were low quality and sometimes not efficient when using custom views and dynamic content.
SwiftUI has simplified animations
Something we really missed in old systems, where you have to fight with
UIView.animate() and more. The new easing and animation system looks way better.
SwiftUI is for sure the step to take if you want to follow Apple’s modern interpretation of UI developing.
If you still need something which will not affect your timing provisioning for a new release or a new project your customer is waiting for, continue to use Storyboards or Auto Layout.
For more information and to build a mobile APP using iOS, Hire iOS Developer from us as we give you a high-quality product by utilizing all the latest tools and advanced technology. E-mail us any clock at – firstname.lastname@example.org or Skype us: “hkinfosoft“. To develop your mobile APP using iOS, please visit our technology page.