I know the headline is misleading: Flutter is a framework, and Swift is a programming language. It should be “Why Dart/Flutter is better than Swift/Standard iOS SDK”. In this article I’m comparing Flutter with a classical way to develop iOS apps: using Xcode, Swift and iOS SDK.
UIKit is buggy and proprietary
UIKit is buggy. Any experienced developer faced such bugs during his career. People have even created a special website tracking those bugs: OpenRadar. The worst thing is we can’t actually do anything with them but wait for a new iOS version: iOS SDK (and UIKit) is embedded into iOS itself. And Apple Bug Reporting program shown itself from bad side. I sent a lot of bug reports, but most of them were closed due to ‘Duplicate’ reason.
iOS SDK is completely proprietary, which makes debugging hard. The only option for us is to find workarounds and hope they won’t break with the next version of iOS.
Flutter is open-source. We can pinpoint the problem and report an issue. Developers can even fix the problem on their own and commit to the Flutter repo. In any case, we are not required to wait an unknown amount of time to get the problem fixed. We can switch between Flutter releases on our own.
iOS SDK is outdated
It was released in 2009, ten years ago. It is written in Objective C and uses many of deprecated paradigms, such as selectors and KVO. The fact that these paradigms are deeply integrated into the SDK forces us to use them instead of more modern, safe and convenient options (closures, notifiers).
Apple tries to move forward though. In 2019 they introduced
SwiftUI a new, declarative way to create app UI.
Swift has certain annoying limitations:
- No abstract classes.
- No generic protocols.
- No async/await (as of Swift 5.1).
Lacking of expressiveness impacts the app architecture in a negative way and forces us to find alternatives and workarounds.
Swift, iOS SDK and Xcode is unstable
Actually, Xcode is pretty stable here: it stops building your project properly every September, when a new version of iOS SDK and Xcode gets released. There are numerous ways things can go wrong: code signing, missing a required module, module incompatibility, Swift syntax change, UIKit or Foundation function change, Apple Mach-O linker error and so on. Sometimes the error message is very strange and not helpful at all. And here we are: instead of developing new features, we google the problem and try to fix it.
Things get even worse if the project is large with a lot of dependencies. We have to hope that guys maintaining our dependencies make sure they work with the new version of Swift, Xcode or iOS. This year guys from Zendesk weren’t able to submit a new version of ZendeskSDK in time, and I had to download the previous Xcode version to be able to run my project. Not fun!
Xcode is a poor development tool
Xcode is the weakest member of Swift/Xcode/iOS Dev SDK. It has too many disadvantages compared to other IDEs:
- It’s buggy. It can crash when you writing a complex piece of code or building a project with many dependencies. Its source code highlighter crashes often too. The worst thing is it barely gets better from version to version.
- No easy way to add extensions. Generally speaking, you stuck with default Xcode functionality and can’t really extend it. Compare it with VSCode with its own marketplace for extensions.
- Xcode Autocomplete and code formatting are poor. Again, I’m comparing with VSCode: its IntelliSense greatly improves my performance, and Prettier extension does all the formatting for you for free.
- Interface Builder doesn’t work properly. Sometimes it can just stop connect outlets with the code.
You might say that these issues are mostly environment and toolset related, not the language itself. I’d agree with that, but we write code using tools, SDKs and IDE we’re given. And Apple doesn’t do a great job with improving these tools. In fact, if you are an iOS developer, you have to use Xcode in some sort of way.
I personally found Flutter more easy to work with tool for iOS development. Dart and Flutter have their own disadvantages, but they both rapidly grows and, at least, listen for feedback from developers.