Everything is Shared (And That’s the Problem)

A story about SwiftUI dependency injection, singletons, and the bug that only shows up when you have two windows open…

Everything is Shared (And That’s the Problem)

A story about SwiftUI dependency injection, singletons, and the bug that only shows up when you have two windows open…

Michael Long
Michael Long in Level Up Coding
  ∙  
October 16, 2026
  ∙  
10 min read
Member-only content
  ∙  
View on Medium
Demo Application Image by Michael Long

Demo Application Image by Michael Long

Most dependency injection systems assume your app has exactly one window.

One process, one screen, one object graph. And a single global container sitting at the bottom of it all, handing out services to anyone who asks. It’s the assumption baked into pretty much every DI library out there, including mine.

And it was a reasonable assumption. Until it wasn’t.

I found that out the hard way while working on SceneGeometry for Runes, my open source collection of Swift and SwiftUI utilities.

Let’s take a look at what happened and what we can do to fix it.

The Duo

Apple recently announced…

Continue reading
This is a member-only story and can only be read on Medium.
Write on Medium
Sent to sikubaycom.s3cr3tz@blogger.com by Michael Long on Medium
Unsubscribe from this writer's email notifications
Manage your email settings

3500 South DuPont Highway, Suite IQ-101, Dover, DE 19901
Careers·Help Center·Privacy Policy·Terms of service