Weeknotes #2

Book and Swift Talk

At the end of last week, we recorded some Swift Talk episodes that build up our new attributed string builder library. This project allows you to build up an attributed string using result builders, from a number of different sources. For example, you can write Markdown, plain strings, use NSImages or even embed SwiftUI views, all combining into a single attributed string with uniform styling.

We plan to use this as the basis for laying out our books. These are mainly written in Markdown, but we want to be able to intersperse the Markdown with SwiftUI views (rendered as vector graphics), other images, and we’d like to have some more layout possibilities. For example, we’d like to have multiple columns for some parts, call-out boxes, tables, and so on. Being able to “drop down” to custom attributed strings allows us to do this while still mainly having our text in Markdown.

I also added support to this blog to render images of inline SwiftUI views inside my posts, although I’m not using that feature yet. Hopefully soon!

We rewrote the start of the Thinking in SwiftUI chapter on view trees. In essence, one of the big insights we had is to start out with describing how view builders construct lists of views, and how almost everything in SwiftUI is a list of (lists of) views. When you have a value that conforms to the View protocol, it’s always a list of views — it being a single view is the exception. We also worked a bit on explaining the two roles of @State in SwiftUI: it’s used to both initialize a state property as well as update it (and these are two very different things!). Finally, we started a rewrite of the Advanced Layout chapter (covering the Layout protocol, preferences, and geometry readers)

I used Nushell for the first time. I saw this in Mastodon a while ago and had it installed. I used it to read a JSON file containing all of our episode metadata, projected only the title and synopsis for each episode, and wrote them to a CSV in reverse order. The code was easy to write and is easy to read. I can totally see myself use this shell every once in a while for odd jobs:

open episodes.json | select title synopsis | reverse | to csv

This week, we again prepared and recorded a few episodes about attributed strings, and put the code on GitHub. We also have some more things we’d like to add (table support) and possibly some extras we could do in a separate package (e.g. syntax highlighting, as this pulls in a bunch of dependencies that most people might not need). Currently, the package is only designed to work on Mac and works with TextKit, not sure whether we’ll have bigger ambitions at some point. We would like to add a nice readme and some samples.

In our new house, I continued renovating and helping out the professionals where I could. I spent a day cleaning the entire construction site, did some final demo, spent two afternoons helping out with the drywall for the bathroom, and a day helping out with bricklaying (even laying some bits myself). We needed to get a bit more done this week, which of course came at the expense of family time. Luckily, busy weeks like this are the absolute exception. (I really enjoy renovating, but lots and lots of family time is more important to me.)

I continued my fermenting process, last week’s ginger bug was ready and bubbling, so I used it to start making a big batch of ginger beer. I also started mead and made overnight bagels (turned out great and the family loved them).

I’m reading Crucial Conversations in the evenings, which is very interesting to me. I’m not sure if I’ll be able to apply the ideas without having a lot of practice, only time will tell.