Codementor Events

Learn how to Master SwiftUI

Published Sep 22, 2022
Learn how to Master SwiftUI

About me

I am a professional programmer who started my programming career with Web development and later switched to iOS. I have been creating apps for iPhone for over 8 years. First, I had to learn Objective-C, then later Swift and now I have been coding in SwiftUI since its release. As I mastered iOS, I started teaching and and have been teaching many student Swift, iOS, SwiftUI, and Objective-C. I am also expert in C/C+ and Web development.

Why I wanted to learn SwiftUI

SwiftUI allows you to create an app without writing complex UI code or using storyboards. It also popular and it is simple to create UI without using the dredded Auto Layout. SwiftUI also is reactive and updates the view as your data gets updated. If you are familiar with Rx Swift you would understand this binding of View and Model. This Rx Pattern, is probably the hardest to get accustomed , since it's a different way of thinking. Swift doesn't provide Reactive programming, unless you use a library. SwiftUI allows you to write animation logic very easily. SwiftUI will also enable you to do rapid prototyping by allowing you to run your code without building and receiving instant updates on your simulator. You don't need to build the code to see the changes you have made.

How I approached learning SwiftUI

I started my SwiftUI Learning Journey, by reading docs on Apple developer website and following the tutorial step by step. I also watched numerous videos on YouTube, and finally started working on my own app. Working on my own app, proved to be the most effective way for me to grasp SwiftUI. The reason this was effective, was because you will always encounter failure no matter how good of a coder you are. You become more proficient in a new language as you challenge yourself to tackle bigger and more challenging problems. The more problems you solve the more advanced you will become. I also tutored several students with their swiftUI issues and continue doing that for years. Tutoring has made me even a better SwiftUI developer.

Challenges I faced

I noticed how SwiftUI forces you not to have logic in your UI code and think differently. SwiftUI doesn't believe in auto layout and neither storyboards. Everything is done using Stacks, and bunch of curly braces. Everything has a closures consisting of a closing and opening curly brace. The curly brace combined with modifier method allows you to see the UI modified on your simulated iPhone. There are no tableViews or collectionViews, and are replaced by Lists, V-Grid, and H-Grid . During development, I noticed I was always searching for something in Swift to find the equivalent in SwiftUI. After researching for hours I was able to to find something. If you are used to Swift UIKit, get ready to learn some of the new views and modifiers in SwiftUI. I had to relearn a lot of the Controls that iOS provides. However you can mix UIKit with SwiftUI.

Key takeaways

When you start learning a new language, at first it will look like you are in unfamiliar territory. You will feel like a child wanting to explore everything. Don't be afraid to explore, but remember that you are not proficient yet. You will fail and your willingness to continue through the many failures you will encounter, will determine your future proficiency in this language. SwiftUI lets you write UI code without using auto layout. SwiftUI allows you to write less code to accomplish more. SwiftUI will be easy at first but hard for complicated projects.

Tips and advice

You don't need to know Swift if you want to learn SwiftUI.
You can learn Swift as your coding in SwiftUI.
If you know Swift SwiftUI can be easier, but not necessarily.
If you are coming from another language you can jump right into SwiftUI.
Watch tutorials to learns SwiftUI and create your own app. Then use tutors if you encounter issues.
Learn how SwiftUI works and how it updates the UI.
Don't memorize SwiftUI concepts make sure you fully understand them.

As you learn SwiftUI become proficient at the following:
Understand Stacks and the view modifiers.
Understand how to pass data from View to another View and dismiss the views.
Learn iOS patterns and UIKit in general to be best iOS dev.
Understand how to stack modifiers work because order matters.
Understand how GeometryReader works.
Understand how spacers and padding work to make your app work on all devices.
Understand ScrollView which comes from UIKit but acts differently.
Understand ZStack, VStack, HStack usage.
Understand how to animate buttons and views.

Final thoughts and next steps

If you are thinking of learning SwiftUI and creating that wonderful app you have been dreaming of, then take the leap and learn SwiftUI. Remember that it won't be easy and you might need a tutor to help you through the hurdles. Reach out to me or any other tutor to help you get unstuck and move you towards successfull completion of your app. As you learn how to tackle hard issues, you will be more proficient to create the next app. Learn SwiftUI now and not tomorrow.

Discover and read more posts from Arbi DerHartunian
get started
post commentsBe the first to share your opinion
Show more replies