Building, Testing, and Scaling With SwiftUI Part 2: Composing View Models

Part 1: Building Previewable Views In the previous post of this series I discussed how important it is for views to clearly define their dependencies in a way that can be stubbed out. We did that by making our view generic over a view model protocol, then having both a production and a stub version of the view model. It looked something like this: protocol PokemonListViewModelProtocol: Observable { var pokemonList: [Pokmeon] { get } func fetchPokemon() async } struct PokemonList<ViewModel: PokemonListViewModelProtocol>: View { @State var viewModel: ViewModel init(viewModel: ViewModel) { _viewModel = State(wrappedValue: viewModel) } // .

Read More

Building, Testing, and Scaling With SwiftUI Part 1: Building Previewable Views

One aspect of SwiftUI that is crucial to my workflows is the SwiftUI Preview system. Previews are an incredibly powerful and sophisticated tool, intelligently recompiling only the code which has been modified, in order to achieve a blazing fast edit-refresh cycle. If you change the String value you pass to a SwiftUI Text view, Previews will recompile that specific view only and nothing else in your view hierarchy, dynamically swapping it in at runtime.

Read More

Why I'm Not Using SwiftData (Yet)

Apple’s SwiftData framework was announced this year at WWDC and it’s what we’ve all been waiting for. A persistence mechanism from Apple, written entirely in Swift for Swift… kind of. The fact is that it’s still the old CoreData framework under the hood, with a sugary layer of Swift on top. While that bodes well in some senses because CoreData is battle-tested, it also means that we continue to carry with us many of CoreData’s idiosyncrasies, which can be either good or bad depending on where you stand.

Read More

How to Make Your Stream Deck Pretty

The Problem The Stream Deck is a powerful tool and with a little TLC you can have an awesome look to go with it. For a lot of needs, the Stream Deck Key Creator tool is plenty. If all you need is a single icon or even a single page of icons, the Key Creator might be enough to satisfy your needs. The Key Creator tool falls short for me in two specific ways:

Read More

How I Set Up a New Mac

Setting up a new Mac from scratch can be a pain in the butt. There are a ton of apps to install and settings to change. This post will serve as a living document for how I like to set up my Mac. This is as much for the benefit of you, the reader, as it is for me. I like having stuff like this documented. So let’s get started:

Read More

My Stream Deck + Keyboard Maestro Setup Is Different

Keyboard Maestro 9 added official support for the Elgato Stream Deck. The official plugin (documented here) is very powerful and allows for two-way communication between Keyboard Maestro and the Stream Deck. That said, it’s also relatively rigid and complicated. Rather than map a trigger to a button, you map a button to a trigger. This has a couple of downsides: If you want to reorganize your Stream Deck layout, you’ll have to go to every macro that you’ve assigned to a button and edit its USB Device trigger in Keyboard Maestro.

Read More