Articles about Swift, iOS Architecture, and a hint of automation

Invest in your developer experience!

The more effort you require to start an activity, the more likely you will put it off.

How long does it take you to open up your personal project?

My experience

I had the idea of exploring how HTTP works, so I thought I would write a simple Chat Server/Client without using any HTTP or Websocket libraries. To bootstrap the project, I thought I’d write a Kotlin SpringBoot server, using a PostgreSQL Database via Docker, and an Android Client.

Running newest Xcode on older macOS version

Every year, Apple releases a new macOS version, and a new version of Xcode. Seemingly these are tied together, and you cannot use the lastest version of Xcode, without first upgrading to the latest macOS version.

After spending a good hour with downloading and extracting the latest Xcode version, if you try to run it, you will be greeted with the following annoying dialog:

MacOS alert asking you to update to the lastest MacOS version

A healthy respect towards unowned

I often ask engineers I’m interviewing how they would use the unowned keyword in Swift. Most of the responses can be categorized into the following:

  • Ignorance: I never used unowned before.
  • Fear: I used unowned before, but it lead to crashes, so I never use it anymore.
  • Madness: I use [unowned self] in every closure.
  • Enlightenment: I would use it in these and these scenarios.

Personally, I find the first three categories of responses unacceptable from a senior engineer. This article is my attempt to guide you towards enlightenment.

Retain Cycles in Swift

Once you get past your initial introduction to Swift and iOS development and start working on a bigger project - especially if you don’t already have a background in programming - you will probably hit your first intermediate level problem: Memory management and retain cycles.

What causes retain cycles?

To answer this, it is required to understand how Automatic Reference Counting (ARC) works. It can be summarized with four simple sentences:

[weak self] is not always the solution

At a certain point in your iOS development journey, you probably encountered a retain cycle when working with closures, which you eventually solves by using [weak self] in the capture list.

If this happens often enough, you might adopt a blanket rule such as:

All closures must have [weak self]!

Yes, this will solve your retain cycles, but it can introduce problems that are worse.

This happened very often with my colleagues, particularly when they are learning reactive frameworks, like RxSwift or Combine, since those make extensive use of closures.

CircleCI - Running special workflows on demand

Recently, I had the pleasure of setting up the CI pipeline for my iOS project at work. Since other projects were already using CircleCI, it was quite natural for us to use it as well.

One hurdle that took me considerable time to solve was figuring out how to trigger workflows on demand. Since I have not been able to find any up to date resources on it, I decided to document my approach in the hopes of helping someone.