SwiftUI is coming, itโs time to say goodbye to UIKit ๐๐ผ
My first impression using this new technology
Great news for Apple Developers! Recently Apple announced SwiftUI at #WWDC19, San Jose, CA. The first time I heard this, I was like, โwhat is this? is this a new language or something? so we need to learn a new language again?โ
This is a big โnewโ that triggered my curiosity, especially after I saw @johnsundellโs tweet about it. Some parts that are previously complicated to code with SwiftUI are now much easier with only a few lines of code writing.
What is SwiftUI?
Better apps. Less code.
SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs. With SwiftUI, you can define what your appโs UI should do with concise, declarative language, and say goodbye to tons of confusing UIKit code ๐๐ผ. Automatic support for Dynamic Type, Dark Mode, localization, and accessibility means your first line of SwiftUI code is already the most powerful UI code youโve ever written.
Try SwiftUI for the first time
The first thing to know is that SwiftUI only supports iOS 13 and iOS 13 is just in Xcode 11 and Xcode 11 it's not released yet so we have to install Xcode 11 Beta for now. And oh! Xcode 11 requires a Mac running macOS 10.14.3 or later but if you want to try SwiftUI with tools development is only available when running on macOS 10.15. Itโs not released yet also so we have to install macOS Beta too.๐ช
My First Look
When I saw the code, I have no idea! There is no resemblance to what we usually use, such as UIKit moreover UIStoryboards and his friends. But, on the other side, this SwiftUI is pretty easy to learn, the code is clean and simple.
Iโm trying to create a movie app using SwiftUI and this is the result:
What I found after trying SwiftUI
Thereโs no AutoLayout. instead, you use things like H/VStack, Groups, etc. SwiftUI replaces storyboards with code, thus it will be very easy to create a reusable view and this is very good because we often get conflict code problems when using storyboards in the project team, with SwiftUI will avoid that problem. ๐๐ป
Dark mode. changes the typical bright theme to a darker one, which can be easier on the eyes, particularly at night. Some people just think it looks better, and I agree. Developers will be able to add dark mode to their apps. I did nothing but my apps support dark mode, itโs really cool. ๐
Live Preview. in Xcode 11 when you use SwiftUI you can real-time review the results of the code you wrote without having to build. This saves a lot of time, but will this feature make the processor work harder? I think yes, because I experienced some lag when using it, or maybe because itโs still just a beta version. ๐ค
Mix SwiftUI and UIKit, donโt worry you no need really to say goodbye to UIKit you can mix that two using UIHostingController. ๐
Conclusion
SwiftUI only works on iOS 13, macOS 10.15, etc. I think SwiftUI will really be used in the next 2 years waiting for users to install the latest iOS unless you really want to make apps that only support iOS13 and above.
There are still many other new things from SwiftUI that must be learned, like me who still don't know how to eliminate the separator line in the List ๐ . I think we still have a lot of time until the time comes when our project really needs to use this new technology.
Thanks for reading! ๐๐ผ if you found this is helpful please give clap ๐๐ผor you got something to add? just write a comment below. Visit my Linkedin profile and also my Instagram connect with me!
Lastly, if you want to check how I made the movie app using SwiftUI you can clone the completed project in the repository below. ๐๐ผ