Switching to Swift UI
Enter iOS and the Apple ecosystem.
With the announcement of SwiftUI we decided to take another look at the native iOS ecosystem and see if this could solve at least some of our issues. We would still be writing and supporting two code bases for our application but we would solve a few problems inherent with hybrid mobile apps. For example with React Native we spent countless hours upgrading minor versions as the native APIs changed. With Ionic we spent countless hours debugging issues with Cordova libraries. Not to mention performance issues on lower end devices.
Why Swift UI
This is by no means an exhaustive list of advantages, these are just some of the reasons we love SwiftUI.
- We no longer need to create complex storyboards and UIKit code.
- With the standard SwiftUI elements like TextField, HStack and Spacer() we have a very
simple method to create the same components as the Vue applications.
- Easy to learn with simple syntax.
- It allows us to easily manage themes and the popular “Dark Mode”
- SwiftUI provides really easy to use state management with @State, @Binding,
@ObservedObject and @EnvironmentObject.
- Live Preview allows much easier work with the visual elements.
- SwiftUI will always produce a valid layout.
- Because we are writing a truly native application we no we shouldn’t run into any major
performance or stability issues.
Whilst SwiftUI is a major improvement over the standard UIKit and storyboard approach, there are still some major disadvantages. These are just a few of the issues we have:
- It supports only iOS 13 and Xcode 11.
- It’s still very young, so there isn’t much community help on Stack Overflow and other
- It doesn’t allow you to examine the view hierarchy in Xcode Previews which has meant
we end up building on the simulator.
- Working with Rest API’s can sometimes generate a ton of complex code.
Our Final Thoughts
Hopefully the above info has given you some insight into SwiftUI and where it may fit into your stack. Whilst it may seem like quite a challenge to get started, once you understand a few basics the development process does become fun! Right now we are planning to stick with SwiftUI as our Vue companion on iOS devices. Apple are looking to support PWA's more in the Safari browser but it’s likely to be some way off.