Building iOS Apps with SwiftUI
SwiftUI is one of the most exciting announcements for iOS developers since Swift was announced five and a half years ago. SwiftUI is a powerful declarative framework that promises to change how developers build out user interfaces for Apple devices. Since SwiftUI was announced almost a year ago, developers have been asking themselves when the right time was to learn and build their first app with SwiftUI. Before answering that question, let's look at some of the pros and cons of SwiftUI.
- SwiftUI is easy to learn, and is much more approachable for a newer developer. There are also great resources and tutorials from Apple that will allow you to get started with the basics of SwiftUI.
- SwiftUI offers a live preview window that updates as you update your code. This allows developers to preview their views without needing to build on the simulator or device.
- Between the live previews and the ease of use with building out the basic views, development is notably faster with SwiftUI once you get the hang of it.
- Anyone who has used storyboards before understands how painful source control changes can be, especially with large storyboard files. It’s nearly impossible to actually know what has changed in a storyboard when someone opens a pull request. Storyboard files also make managing merge conflicts between developers very frustrating. With SwiftUI you won’t have to worry about these problems caused by Storyboards and Interface Builder.
- You can mix SwiftUI with UIKit, so it is possible to start building new views with SwiftUI in existing apps that were originally built with UIKit
- The biggest drawback is that SwiftUI only supports iOS 13 and higher. So this will be a deal breaker for many developers who want to continue to support older iOS versions.
- SwiftUI is still a young framework that is constantly updating. With WWDC coming up in June, I’m expecting to hear about some major updates and changes to SwiftUI.
- Debugging with SwiftUI can be challenging, especially for beginners, because the error messages in Xcode don’t always point to the correct spot. Xcode will tell you that something is wrong, but it won’t point to the error. So you’ll need to hunt down the issues in your SwiftUI code.
- Because SwiftUI is still young, it is tougher to find help with more complex issues when looking for answers on StackOverflow and elsewhere.
It seems clear that SwiftUI is going to be the future standard for iOS developers, but it is still going to be awhile before we get to that point. I do think it is beneficial for experienced Apple developers to start learning and adopting SwiftUI, as I believe it will entirely replace UIKit within the next couple of years. But for new and beginning iOS developers, I would also recommend starting with UIKit. Especially if you are hoping to get a professional iOS development job.
I do think we will slowly see more and more new apps being built with SwiftUI in the coming year. Especially after the next iOS version is released, and as supporting devices below iOS 13 is less of a concern. But it is hard to see the value of any existing applications being rebuilt in the near future with SwiftUI.
Some dev leaders will also want to wait until SwiftUI has matured to start using it. So while SwiftUI is certainly the future for iOS development, I think we are at least a couple years away from SwiftUI being the new industry standard. That won’t stop us at Entrision from starting to use it on our new projects though. We’re excited about taking advantage of the benefits it brings to the table.