Sitemap

Re: UIKit/AppKit-Free SwiftUI App

In this short read, I revisit my SwiftUI app in an attempt to remove the last remnants of UIKit and AppKit.

3 min readAug 26, 2025

--

In last year’s revision of my iOS/macOS app Worm, where I explored the state of Apple’s SDKs, I complained that I couldn’t quite get rid of UIKit/AppKit. The blocker was Image — specifically, creating one from data downloaded over the internet.

Back then, my solution was to create a UIImage/NSImage from Data and initialise Image from it. I claimed there was no other way.

I was wrong.

Not a member? Read here for free.

A view on the Italian Alps
Image courtesy of Anna Lazareva-Zubova

But before we get to the better approach, let’s look at what I had been doing before.

The Wrong Way

At the time, I was rather proud of the workaround I built to smooth over the differences between iOS and macOS SDKs.

First, I defined a universal type alias:

#if os(iOS)
import UIKit

typealias UniversalImage = UIImage
#elseif os(macOS)
import AppKit

typealias UniversalImage = NSImage
#endif

Then, I wrapped it in a SwiftUI view that worked on both platforms:

import SwiftUI

struct UniversalImageView: View {

var body: some View {
#if…

--

--

Nikita Lazarev-Zubov
Nikita Lazarev-Zubov

Written by Nikita Lazarev-Zubov

Swift and general programming topics, Agile software development, soft skills

No responses yet