For the past ten days or so, I have been trying to gain some basic competency with SwiftUI.

I have found it hard. Very hard. But I finally feel there is a sliver of light in my comprehension. Just enough to give me the confidence to write this here, thinking there may be more posts on SwiftUI to come.

Why so hard

My aims for SwiftUI are the same as they are with web technologies; principally, to make high-fidelity prototypes to test out designs. SwiftUI will just give me another medium to work with, and hopefully negate the need to make prototypes for native app features in a different medium; web tech.

And so I set out watching and reading and trying to get my head around SwiftUI.

At the outset, I was very encouraged. Conceptually, SwiftUI, surely by no mistake, is very reminiscent of web frameworks like lit.dev and React. Something I am comfortable with.

Components are essentially ‘Views’ in Swift parlance, and in SwiftUI, you pass state, or reference state from some global location, and the declarative View that you have written updates to the new state.

So, with such familiar conceptual underpinnings, I don’t know why I have found it so hard to start to use SwiftUI.

“…I’m too old for this shit”

However, a few days in, the thought crossed my mind that maybe, like the fact my body can no longer manage a full game of football, my mind simply lacks the elasticity to learn new things?

I was watching and watching, reading and reading, trying to make things, just simple things, any thing, in Xcode and it just was not happening.

A kind of fear gripped me.

Writing the correct syntax seemed like simply memorizing some bizarre magic incantation, with no basis in logic. Add to that, that, unlike on the web, where techniques from the past live for all eternity, in SwiftUI, at Apple’s convenience, they are simply removed. So something that reasonably worked in 2021, does absolutely not work in 2024. Or gives you so much warning in the editor, you couldn’t in good faith leave it in.

For example, good ol’ ChatGPT would keep telling me with insistence I should use NavigationView which is simply not a thing in later iOS versions.

Frustration heaped onto frustration, as things like reading in a JSON file to iterate over it in the UI remained unfathomable to me.

I spoke to colleagues, they suggested treating it like first experiences with the web, and just get images in and see if you could navigate between them as faux ‘pages’ of the app rather than make pages with ‘real’ content.

I subsequently scaled back my already humble ambitions further.

More days of fruitless labour followed, every step forward presented two steps back as some new blocker revealed itself. I started to write up each new issue and ask the question on the ‘Hacking with Swift’ forums (I have pretty much given up on Stack Overflow as it seems near impossible to ask any question that isn’t immediately shut down as a ‘duplicate’).

I was going to bed each evening with my head ‘humming’, and waking up with a sense of dread.

I had looked at SwiftUI a couple of years back and been equally frustrated and ultimately retreated back to the warm embrace of web technologies. However, this time, I didn’t feel that retreating was an option. But I was 100% not having a fun time.

Something changed

Then yesterday, something altered, subtle but noticeable. I had started to get an intuition for what would work and what wouldn’t. To some degree perhaps, a sense of what SwiftUI was expecting with the simplest of interactions.

Let me be clear. These are the very beginning of steps along a journey. Absolute basic stuff. But I at least feel I am starting to occasionally shuffle my progress forward, in the belief I will one day walk.

At the outset there wasn’t a hole in my knowledge, there was NO knowledge. Now, I at least feel there is a merely a gaping chasm to cross.