mailwal

Swift Dependency Injection: The Singleton strikes back | Not only Swift - Issue 107

Peter Friese from Not only Swift
Not only Swift #107
Issue #107 • October 22, 2026
At the intersection of Apple platforms and agentic AI
Michael Long on iPhone Duo and singletons in Swift dependency injection, Felix Rieseberg on being more ambitious with models, calming down Claude with REVIEW.md, App Attest, OSLog, and positioning SwiftUI views around the fold.

Hi everyone!

Every new technology requires us to relearn how we think and work. At swiftCon 2026 in Berlin, Gio gave a talk titled “Just One More Prompt: Why Agentic Coding Hooks Us”. He cited research that was conducted with gamblers in Las Vegas, and made the point that using coding agents can hook us in a similar way - just one more prompt…

Felix Rieseberg takes a different viewpoint - he argues that AI allows us to elevate our work to levels previously unthinkable (quite literally), and suggests a couple of ways how you can integrate this into your own work.

As with any new technology, it will take time for all of us to learn how to use it responsibly and effectively.

At the same time, new hardware form factors such as the iPhone Duo can have unexpected implications on our app architecture - read Michael Long’s article about dependency injection to understand how the single most evil design pattern singletons can wreak havoc in your apps.

As always, hit reply to let me know what you’re thinking (or to suggest articles that other readers might find interesting).

Cheers,

Peter

Sponsor this newsletter: Reach 1,960+ Swift and Apple platform engineers with your product, project, or event. View available dates →
What I am working on

Over the past couple of years, I’ve given countless talks and workshops at meetups, conferences, and online events. At last count, there were about 300 Keynote files on my computer. That a whole lot of “Hello, everyone, thanks for coming to my talk!” moments!

As I mentioned in the previous newsletter issue, I somewhat surreptitiously got into building a new presentation software called LimeLight.

It looks a bit like Keynote, but instead of designing your slides visually, you use Markdown. LimeLight then renders your Markdown into slides, freeing you from having to think about the visual layout of your slides and instead allowing you to focus on the content.

LimeLight screenshot

Now I know what you’re thinking - “Markdown for slides? Isn’t that a bit limiting?”

Well - I made sure that LimeLight is powerful enough to build complex and visually compelling presentations. Here are a few examples:

Animated code slides

LimeLight uses the same ideas as DocC - it detects the differences between two code snippets, and animates the changes to help viewers follow along.

LimeLight screenshot

Callouts

To use callouts in LimeLight, you just define a footnote and then define a couple of parameters to specify the position and style of the callout.

LimeLight screenshot

Inline devices

But the real killer features is the ability to embed live previews of your physical devices (or the Simulator) directly into your slides. No more switching back and forth between your slides and the device preview - everything is right there in the presentation!

LimeLight screenshot

Swift

One of my toxic traits is that I often use print for debug logging even though I am fully aware there are much better options. Print logging has been around for as long as I can remember. It might appear to be super easy and convenient, but it will come back to bite you later.

For example, when you accidentally leak API keys or your users’ personal data into your app’s logs.

Here is Sagar to explain how to use OSLog instead and why it is better in every way.

SwiftUI

New form factors often expose problems in your codebase that you weren’t even aware of. One of those problems, surprisingly, is singletons. I mean - come on, it’s 2026, and we’re still using singletons? Old habits die hard, I guess.

I’ve been a huge fan of Factory, and its predecessor, Resolver by Michael Long. Both are dependency injection frameworks that make use of idiomatic Swift.

In this article, Michael explains that the iPhone Duo exposed a critical flaw in how Factory (and basically any other DI framework) handles shared state, and how to resolve (🥁) it.

I’ve just pre-ordered an iPhone Duo and was told that it won’t ship until early January.

So now I have more than two months to look forward to getting my hands on it… What better way to spend the time than reading articles about how to properly support this new form factor?

Here is one by Natalia that explains how you can arrange views around the fold and other hardware elements that are special about the iPhone Duo. Apple seems to have done a good job of exposing the necessary information in a way that allows developers to adapt layouts for other, yet unreleased, devices as well.

Code

Protecting the communication between your application and its backend is more important than ever. For example, you want to make sure that nobody can hijack your backend to tunnel through to the AI service you’re using.

App Attest lets your server verify that an incoming request originates from a legitimate instance of your app running on an untampered device. It’s also the foundation for Firebase App Check, which provides protection for Firebase services (such as Firestore, Auth, and AI Logic), and even your own custom backends.

If you ever wanted to know how Firebase App Check works, you should read Artem Mirzabekian’s article, which explains the underlying technology.

AI & Machine Learning

Coding agents tend to be very verbose when giving feedback, and that can really drain your energy - decision fatigue is a real thing!

This article by Joe Fabisevich explains how to teach Claude for GitHub to tone it down. The techniques used can be applied to pretty much every coding agent, so it is definitely worth checking out.

Every new technology requires us to relearn our thinking. I feel at the moment we try to do more, but it also requires us to work harder, to think harder, to keep more things on top of our mind.

Felix Rieseberg shares how you can be more ambitious with models. One of the key ideas is to operate at a higher level.

How do you do that?

By telling the model to help you identify what you don’t know, and help you to fill in the blanks.

Apparently, many other people were also inspired by this, and some people even turned it into skills or prompts: Alex Prompter turned it into 7 prompts, and Danny McAteer created an agent skill based on it.

I wrote about decision models a while ago, and I’ve even implemented a Swift package that allows you to use the most popular decision models in your Swift apps.

Many demos showcase the amazing ability of decision models to decide really fast. Triaging emails or making quick recommendations are the more boring use cases, playing racing games is more exciting.

In this article, Alejandro Martinez explains that decision models can be unsure about their decisions. He goes on to make the point that this is actually a useful property, as it allows the model to hand off the decision to a human in the loop.

Business & Strategy

This tweet made it sound like Apple is no longer permitting developers to use A/B testing or feature flags in their applications. If that was the case, it would be pretty bad news indeed.

As pointed out in Apple’s developer update, the new guideline 2.5.19 is a clarification for guideline 2.3.1. So it is not something new, but Apple felt the need to be more specific about it.

Tools & Tips

Last week I shared a link that shows you how to create a blueprint icon for your app. This week we’ve got an article that talks about making sure your action extension has a nice icon.

Muhammad shares one of those obscure pieces of knowledge that are not well documented elsewhere.

Conferences
iOS Conferences in 2026

Here is your updated list of conferences for iOS, Swift, and AI.

We’ll be hosting the Agentic Hamburg meetup at the Google office in Hamburg on November 3rd - hope to see you there!

Upcoming conferences

Thanks for being a Not only Swift subscriber!
All my content is available to you for free. Like what I do and want to support me?
Put something in my tip jar. Thanks!
I post regularly on other platforms, and it would mean the world to me if you followed me on:
Juetlandring, Hamburg, Hamburg 22419
Did you know you can let me know what you're most interested in? Update your preferences - this will help me write what you love reading!