Recent articles

Jump to a random post

Choosing between LazyVStack, List, and VStack in SwiftUI

Published on: May 8, 2025

SwiftUI offers several approaches to building lists of content. You can use a VStack if your list consists of a bunch of elements that should be placed on top of each other. Or you can use a LazyVStack if your list is really long. And in other cases, a List might make more sense. In this post, I’d like to take a look at each of these components, outline their strengths and weaknesses and hopefully provide you with some insights about how you can decide between these three components that all place content on top of each other. We’ll start...

Read more...

Differences between Thread.sleep and Task.sleep explained

Published on: May 1, 2025

In Swift, we have several ways to “suspend” execution of our code. While that’s almost always a bad practice, I’d like to explain why Task.sleep really isn’t as problematic as you might expect when you’re familiar with Thread.sleep. When you look for examples of debouncing or implementing task timeout they will frequently use Task.sleep to suspend a task for a given amount of time. The key difference is in how tasks and threads work in Swift. In Swift concurrency, we often say that tasks replace threads. Or in other words, instead of worrying about threads, we worry about tasks. While...

Read more...

Protecting mutable state with Mutex in Swift

Published on: April 30, 2025

Once you start using Swift Concurrency, actors will essentially become your standard choice for protecting mutable state. However, introducing actors also tends to introduce more concurrency than you intended which can lead to more complex code, and a much harder time transitioning to Swift 6 in the long run. When you interact with state that’s protected by an actor, you have to to do so asynchronously. The result is that you’re writing asynchronous code in places where you might never have intended to introduce concurrency at all. One way to resolve that is to annotate your let's say view model...

Read more...

Using singletons in Swift 6

Published on: April 23, 2025

Singletons generally speaking get a bad rep. People don’t like them, they cause issues, and generally speaking it’s just not great practice to rely on globally accessible mutable state in your apps. Instead, it’s more favorable to practice explicit dependency passing which makes your code more testable and reliable overall. That said, sometimes you’ll have singletons. Or, more likely, you’ll want to have a a shared instance of something that you need in a handful of places in your app: class AuthProvider { static let shared = AuthProvider() // ... } In Swift 6, this will lead to issues because...

Read more...

Using Instruments to profile a SwiftUI app

Published on: April 16, 2025

A key skill for every app developer is being able to profile your app's performance. Your app might look great on the surface, but if it doesn’t perform well, it’s going to feel off—sometimes subtly, sometimes very noticeably. Beautiful animations, slick interactions, and large data sets all fall flat if the app feels sluggish or unresponsive. Great apps respond instantly. They show that you’ve tapped something right away, and they make interactions feel smooth and satisfying. To make sure your app behaves like that, you’ll need to keep an eye on its performance. In this post, we’ll look at how...

Read more...

Staying productive as an indie developer

Published on: April 9, 2025

Okay. I’m using the term indie developer loosely here. I don’t consider myself to be an indie developer. But I am independent, mostly. I run my own business where I work on client apps, workshops, my books, this website, my YouTube channel, and more. So I think I qualify as indie, partially. Either way, in this post I’d like to explore something that I don’t write or talk about much. How do I, as someone that manages my own time and work, make sure that I stay productive (in a sustainable way). A lot of folks that I’ve talked to...

Read more...

Implementing Task timeout with Swift Concurrency

Published on: April 1, 2025

Swift Concurrency provides us with loads of cool and interesting capabilities. For example, Structured Concurrency allows us to write a hierarchy of tasks that always ensures all child tasks are completed before the parent task can complete. We also have features like cooperative cancellation in Swift Concurrency which means that whenever we want to cancel a task, that task must proactively check for cancellation, and exit when needed. One API that Swift Concurrency doesn't provide out of the box is an API to have tasks that timeout when they take too long. More generally speaking, we don't have an API...

Read more...

How to plan a migration to Swift 6

Published on: March 6, 2025

Swift 6 has been available to us for the better part of a year now, and more and more teams are considering or looking at migrating to the Swift 6 language mode. This typically involves trying to turn on the language mode or turning on strict concurrency, seeing a whole bunch of warnings or errors, and then deciding that today is not the day to proceed with this migration. Today I would like to propose an approach to how you can plan your migration in a way that won’t scare you out of attempting the migration before you’ve even started....

Read more...

What’s new in Swift 6.1?

Published on: February 27, 2025

The Xcode 16.3 beta is out, which includes a new version of Swift. Swift 6.1 is a relatively small release that comes with bug fixes, quality of life improvements, and some features. In this post, I’d like to explore two of the new features that come with Swift 6.1. One that you can start using immediately, and one that you can opt-in on if it makes sense for you. The features I’d like to explore are the following: Changes to Task Groups in Swift 6.1 Changes to member visibility for imported code We’ll start by looking at the changes in...

Read more...

Why you should keep your git commits small and meaningful

Published on: February 19, 2025

When you're using Git for version control, you're already doing something great for your codebase: maintaining a clear history of changes at every point in time. This helps you rewind to a stable state, track how your code has evolved, and experiment with new ideas without fully committing to them right away. However, for many developers, Git is just another tool they have to use for work. They write a lot of code, make commits, and push their changes without giving much thought to how their commits are structured, how big their branches are, or whether their commit history is...

Read more...