Majid's blog about Swift development

SwiftUI learning curve in 2019

This year we had a massive change in iOS development world. We got a SwiftUI framework. SwiftUI is a brand new declarative way of building apps for Apple ecosystem. Let’s build our learning curve. I want to share with you the list of all the needed posts to learn SwiftUI.

Basics

Apple did an excellent job this year by creating the SwiftUI tutorials page. I suggest starting with those tutorials to learn the basics of SwiftUI.

One of the new features of the Swift language powering SwiftUI framework is property wrappers. To learn about the most important property wrappers like @State, @Binding, @ObservedObject, @EnvironmentObject, and @Environment read my “Understanding Property Wrappers in SwiftUI” post.

Another post that I wrote about the mechanics of SwiftUI is “You have to change mindset to use SwiftUI”. It should help you to understand how SwiftUI works under the hood.

Layout system

SwiftUI also has a brand new layout system, which I enjoy much more than AutoLayout. The new layout system is very powerful and straightforward. I highly suggest you read these posts to understand the new layout system and its benefits.

  1. SwiftUI Layout System
  2. Inspecting the View Tree – Part 1: PreferenceKey
  3. Inspecting the View Tree – Part 2: AnchorPreferences
  4. Inspecting the View Tree – Part 3: Nested Views

Architecture

SwiftUI has a lot of similarities with React framework, which brings many new concepts to iOS development. I’ve built a few apps using those ideas and really like how it works. Here is the list of useful posts.

  1. Introducing Container views in SwiftUI
  2. Modeling app state using Store objects in SwiftUI
  3. Redux-like state container in SwiftUI

Declarative nature of SwiftUI

SwiftUI is a declarative framework. It means you declare what you want to achieve, and the framework takes care of that and decides how to render your views. The very same view can have another look, depending on the context. I wrote a few posts about the declarative approach in SwiftUI.

  1. Building forms with SwiftUI
  2. View composition in SwiftUI
  3. Reusing SwiftUI views across Apple platforms
  4. ViewModifiers in SwiftUI
  5. Composable styling in SwiftUI

Animations and interactions

SwiftUI handles all the state changes using animations just for free for you. It allows us to build interactive views in a very straightforward and nice way. I covered this topic many times on my blog.

  1. Animations in SwiftUI
  2. Gestures in SwiftUI
  3. Building Bottom sheet in SwiftUI
  4. Building Pager view in SwiftUI

I also want to mention the excellent series of posts by Javier about advanced animations in SwiftUI.

  1. Advanced SwiftUI Animations – Part 1: Paths
  2. Advanced SwiftUI Animations – Part 2: GeometryEffect
  3. Advanced SwiftUI Animations – Part 3: AnimatableModifier

Accessibility

SwiftUI did another step to make our apps accessible by default. It works very well out of the box, but it also provides a very nice API to customize the accessibility tree. To learn more about accessibility in SwiftUI, I suggest reading these articles:

  1. Accessibility in SwiftUI
  2. Dynamic Type in SwiftUI
  3. Localization in SwiftUI

Drawing custom views

SwiftUI provides a lovely Shape API that allows us to build custom views quickly. I learned it while making charts in one of my apps.

  1. Building BarChart with Shape API in SwiftUI
  2. Gradient in SwiftUI
  3. GeometryReader to the Rescue

Unique features

SwiftUI has unique features like Environment and Preferences, which we don’t have in UIKit. To learn more about these features, take a look at the next posts.

  1. The power of Environment in SwiftUI
  2. The magic of view preferences in SwiftUI
  3. The power of @ViewBuilder in SwiftUI

Conclusion

It was a huge year, and I hope we will get SwiftUI 2.0 with a lot of new features during WWDC 2020. We have many things to learn until the next release of SwiftUI. Let’s say thanks to our awesome community which wrote all these articles. Merry Christmas and Happy New Year!