StoryBoard and SWIFT UI


The storyboard is a part of interface builder which has been the most common way to create UI for iOS applications after its release with iOS 5. Any new iOS project has a Main.storyboard file by default.
“The Interface Builder editor within Xcode makes it simple to design a full user interface without writing any code. Simply drag and drop windows, buttons, text fields, and other objects onto the design canvas to create a functioning user interface.”

This is what the apple documentation says about interface builder. A Storyboard in Xcode is a file which contains an empty canvas type screen. On it we can drag and drop all types of objects available in the object library of Xcode. We can create almost everything from controllers to text fields to images to table views to buttons, all this without writing even a single line of code. You can add controller screens like a table view controller, navigation controller, etc. by just a drag and drop from the object library. You can add segues and move through different screens. Even the smallest components like labels, image, textfields all of it can be dragged and dropped from the object library. Isn’t this just amazing?
Let’s go through some of its advantages first:
It iseasyto learn for even a beginner.
With storyboard you can create a prototype of an app barely in an hour or two, which makes it easy tovisualizethe app without writing hundreds thousands line of code.
The storyboard object library has avast collectionof objects.
It also has alarge community support network.
With great advantages, there are also some drawbacks with the storyboard:
Source controlis difficult, since the storyboard code is in an xml type format it is very difficult to resolve merge conflicts as you cannot completely understand the code.
While creating the application UI you have to keep in mind theAutolayout issuesthat they should work with all thesupporting device sizes, you need to separately check on all devices using the preview option or running the app on each device.
As the number of screens keeps increasing themanagement of storyboardscan becomeverychaoticand as it forms a complex web-like structure.

Swift UI

Swift UI was released with the release of iOS 13.
“SwiftUI helps you build great-looking apps across all Apple platforms with the power of Swift — and as little code as possible. With SwiftUI, you can bring even better experiences to all users, on any Apple device, using just one set of tools and APIs.”
This is what the apple documentation says about swift UI. Swift UI is basically a toolkit released by apple to create UI’s in a declarative way.
A single framework formultiple iOS platformapps (macOS, iOS, iPad apps).
It offers anautomatic live previewoption which is like a hot reload that shows the changes made in the code immediately on view.
There areno Autolayout issuesas in the storyboard.
It offers bothdrag and dropthrough the object library as well aswriting code in filefacility.
The code issimpleandclean.
Swift UI view elements can be easilyreused, by creating smaller module files.
It gives way toreactive programmingby providing bindable objects.
You can alsomixUIKitandSwiftUIby usingUIHostingController.
It supports only iOS 13+ andXcode 11+, so youcannot build lowerversion appsusing this.
It is still very new, there arenot as many component optionsin the swift UI like in the storyboard object library. So you have to create custom views to fulfill requirements, eg: Search bar.
It could be difficult for someone to switch from storyboard to swift UI as it isdifficult to visualizethe view hierarchy in the form of code.
There is no direct way ofmigratingfrom storyboard to swift UI. This compels a developer to continue the use of the storyboard for existing apps and in lower versions.
Since, it is very new so there isless community supportwhich is not the case for storyboard.


After looking at the pros and cons of both Storyboard and SwiftUI, according to my opinion building app UI using storyboard is comparatively easier for a beginner, and has been there was a very long time, but there are some flaws with it and that flaws have been taken care of in Swift UI.
Swift UI also has its set of flaws, but it can be seen that those flaws can be overlooked in front of the advantages that it holds and also that Swift UI holds a lot of potential for the future. So in my opinion, you should definitely give Swift UI a shot, and learn and understand it. Because once you start with Swift UI there is no turning back, with the amount of features it is offering, I think it is definitely a promising UI development toolkit candidate for the future. ✨✨
You can also take a look at this Single view iOS application using swift UI, if you want a taste of swift UI application:

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.