Improve your unit tests and increase maintainability

Photo by ThisisEngineering RAEng on Unsplash.

One of the hardest things with testing your Swift code is getting started. The blank canvas of a fresh app can be intimidating and it’s easy to postpone writing your tests until you’ve finished writing some code.

“I’ll get to it when I’ve written some code so I know what the architecture of the app is going to look like. This will make it easier for me to add tests later.”

This often leads to a situation where you’ve written plenty of code and suddenly it becomes even harder to start writing tests because, well, your code has essentially become…


Get rid of unnecessary Swift dependencies

Photo by Michał Parzuchowski on Unsplash

When starting a new Swift project, developers tend to plan ahead: “Oh, I need networking, I’ll make sure to add Alamofire.”, or: “We want to use Functional Reactive Programming, let’s add RxSwift/ReactiveSwift.”. Maybe you need to parse some JSON and have always used SwiftyJSON, so why not add that as well? However, starting a new project (or performing an update) also gives you an opportunity to evaluate your options again: does my project actually need all these third party dependencies? Let’s find out.

The Use of External Frameworks

There’s a myriad of reasons why you would want to use external frameworks in your apps and…


Get a grip on your SwiftUI views when returning mixed content. Common pitfalls and how to solve them

Photo by Hello I'm Nik 🎞 on Unsplash.

Introduction

SwiftUI introduced us to a whole new way of designing and coding interfaces. Gone are the old ways of subclassing UIKit (or AppKit) classes and hardwiring layout constraints. Instead, we now have a nice, declarative way of structuring and styling our controls and making sure the interface updates whenever new information or events arrive.

To facilitate this new architecture, the good people at Apple took some of Swift’s best features (e.g. protocols, generics, opaque types) and combined them into SwiftUI. However, this comes at a hidden cost: If you’re not already well-versed in these features, there will be a bit…


Faster math in Swift

Photo by Ashraf Ali on Unsplash

Introduction

Apps are super fast and really responsive … except when they’re not. Whenever you’re dealing with mass computation in your code, there’ll be a point where your functions are slowing down and you find yourself staring at your code wondering why this simple addition, multiplication, or division is bringing everything to a halt. Weren’t we supposed to have supercomputers in our pockets?

Luckily for us, modern CPUs are actually quite fast. But you, the coder, also need to know how to present your mathematical code in such a way that it can be executed very efficiently. …


Learn how easy it is to get started testing your SwiftUI components

Every once and a while, it’s a good idea to just take a moment from working on your projects to take a step back and see what’s currently happening in your field of development. Fortunately, for iOS developers that moment comes (at least) once a year when Apple starts announcing the new features for iOS at WWDC.

One of the major announcements Apple made in 2019 was the addition of SwiftUI to the iOS development toolkit. It’s not meant as a direct replacement of UIKit, but it’s certainly a more modern approach to building user interfaces. …

Sjoerd Tieleman

Swift/Ruby/whatever. I’m a freelance software developer based in The Netherlands. Figuring out new stuff is what makes me tick. 🤓

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store