I was, like many iOS developers, shocked last week when SwiftUI was announced at WWDC 2019. Although, in hindsight, the "Protocol-Oriented Programming in Swift" session I attended in 2015 now makes much more sense as to why it was so heavily emphasized. SwiftUI may (and probably will) completely change the way we develop iOS, and now, macOS apps (see Project Catalyst). One of the smartest things I have seen was this tweet from John Sundell. I could not agree with him more. SwiftUI is a completely new development paradigm for the Apple ecosystem. It provides us with a way to develop for all five platforms (macOS, iOS, iPadOS, tvOS, and watchOS) with one framework and currently the only way to build a native app for a watchOS only app. There is much for developers to be excited about in relation to the future with SwiftUI. However, as an educator should I be as excited?
How should I view SwiftUI as someone who teaches iOS app development in Swift to high school students? To try to answer this question for myself I took a look at the Apple Developer site SwiftUI tutorials and decided to build the first part of the Landmarks tutorial app. Here is what I got in about 45 minutes:
I then built a more self-centered variation of the first part of the Landmarks tutorial app.
The projects were easy to build and I enjoyed the learning experience. It is quite a change to be dragging in elements into the Swift file or Command-clicking the element in the preview to add a VStack or HStack (known as Vertical Stack View and Horizontal Stack View in UIKit). I find all of the required interaction with the trackpad to add the elements from the Object Library to be a bit cumbersome. I prefer to keep my hands on the keyboard as much as possible, but I am sure I will be able to do this and enter the elements programmatically once I know SwiftUI better. Although, I suspect that the ability to add UI elements by dragging them to the live preview or into the .swift file (😲) will be extremely beneficial for teachers working with new coders.
SwiftUI is something that may be very helpful for educators somewhere down the road in a few years. We, as educators, do not need to start planning for a near-term change in our curricula. UIKit is not going away. Developers will be able to build UIKit apps for years to come. Additionally, we will have to decide if there is a benefit to our students in switching to SwiftUI. There is some great benefit to teaching Outlets, Actions, Classes, inheritance, and object-oriented programming as these things are used in other programming languages and environments. As for me and my students, we will continue to learn and build apps in Swift using UIKit until we have a compelling reason to switch to SwiftUI.