Weekly Swift articles, podcasts and tips by John Sundell.

Newsletter: February 2020

Published on 01 Feb 2020

👋 Hi everyone

The first month of this new decade turned out to be a quite busy month for me — with 2020 kicking off with the return of my Basics article series, new prototypes, and my YouTube debut. I’m still hard at work on a few bigger projects that will launch later during the year, but I feel like this year is off to a good start.

Here’s your summary of all things Swift by Sundell from January 2020, some open source news, as well as a mini-article about why I build prototypes. Hope you’ll enjoy it — your feedback and suggestions are, like always, more than welcome.

📖 Weekly articles

For 154 weeks, I’ve been publishing a new article about Swift every Sunday. These articles were added during the past month:

Writing reusable Swift extensions

A look at what goes into writing type- and protocol extensions that can be reused between different use cases and projects, and what sort of principles that can be good to keep in mind when doing that.

Test assertions in Swift

In this article we’ll take a look at various ways that we can assert that our code produces the right outcomes within our unit tests, including how we can create our own assertion functions.

Property wrappers in Swift

Let’s take a look at how Swift’s property wrappers work, and explore a few examples of situations in which they could be really useful.

Swift’s closure capturing mechanics

An in-depth look at the various ways that Swift closures can capture the objects and values that they depend on, and how we can control those mechanics.

Remastered: Under the hood of Futures and Promises in Swift

A brand new version of my article about building a Futures and Promises implementation from scratch, completely remastered for Swift 5.1.

🎧 Podcast episodes

The Swift by Sundell podcast is a bi-weekly show featuring special guests from all around the Swift community. You can find it in your podcast player of choice, for example Apple Podcasts or Overcast. These episodes were published during the past month:

64: “Earning the deeper look”, with special guest Sean Allen

Sean Allen helped me kick off the fourth season of the show by joining me to talk about interview processes, goal setting, prioritizing projects, and what we might expect from Swift and Apple’s developer tools in 2020.

65: “Tools are just apps”, with special guest Gui Rambo

On this special Stacktrace cross-over episode of the show, Gui Rambo joined me to talk about building custom developer tools, how open Apple’s tooling really is, writing “Swifty” code versus shipping great user experiences, and much more.

⭐️ Swift tips

I love to share shorter tips, tricks and techniques with the community. These are the tips I shared during the past month:

Using Self to refer to enclosing types

Making extensions on generic types more compact using the Self type.

Result’s convenience APIs

A look at some of the APIs that Swift’s built-in Result type ships with.

✅ Basics

With the Basics series, my goal is to build up a comprehensive library of articles that cover most of the core aspects of Swift and iOS development. This article was published during the past month:

Access control

An overview of Swift’s five different levels of access control, how they work, and when each of them might be useful in practice.

📺 Swift Clips

Introducing Swift Clips, a brand new series of shorter YouTube videos about Swift tips and techniques. This first video was published during January, and more will follow in February:

First class functions

In this first episode we’ll take a look at first class functions, which is a language feature that enables us to use functions in really powerful ways.

🚀 Open source news

It’s always really hard to know how an open source project will be received by the community. After all, so many open source projects (mine included) start out as simpler tools built for very specific purposes — so even though such a tool might be redesigned to become more generally applicable before sharing it, you can never really know whether other developers and teams will actually find it useful.

That’s why I’m so incredibly happy to see my suite of Swift static site generation tools — Ink, Plot and Publish — not only be used by many developers around the world, but to also see so many people contribute back to them. In fact, within the two first months since I started the process of open sourcing them (starting with Ink at the end of November), over 90 pull requests have been merged — which is truly incredible to see.

There are still a lot of improvements to be made, of course, but I think these three tools are off to a great start — which makes me feel like all of the hard work that went into generalizing them to become proper open source projects was totally worth it.

👀 Behind the scenes: Why I build prototypes

I absolutely love prototyping. Not only because it lets me validate an idea or solution without first having to build a production-quality implementation of it, but also because it lets me learn new techniques and technologies by solving actual problems.

Earlier this week, I shared a short video of a Swift editor prototype that’s capable of auto-generating data models based on how they’re being used. That’s a concept that I’ve been thinking about for years now, but it always felt like an impossible task — something too big and too complex for me to solve as a single developer. However, once I actually sat down and made a list of what building a basic version of that concept would require, my thinking quickly started to shift.

It turned out that I already had all of the parts needed to solve my problem — perhaps not in a “production ready” kind of way, but in a way that would let me explore the problem by building a prototype. Cocoa’s NSTextView is all that’s needed to implement a fully capable text editor on the Mac, and I already had Splash for syntax highlighting — a task which requires identifying code tokens like types, properties and function calls.

So to build a quick prototype, all that I needed to do was to put those parts together, to inject a little bit of logic into Splash to make it capture all types and properties that were encountered during the syntax highlighting process — and to then generate implementations based on that data. Done!

That’s why I build prototypes. More often than not, they let me prove to myself that a problem turned out to be much simpler than what I first expected, at least when it comes to building a very first iteration of a solution — which can contain as many shortcuts and “hacks” as it needs to. After all, I don’t intend to share my prototype code with anyone, or to use it to build any shipping products, and just that fact alone can be incredibly liberating — as it lets me explore new techniques, solutions and ways of thinking without a lot of constraints.

😊 Until next time

That’s it for this edition! I hope you enjoyed this newsletter. Like always, I’d love to hear your feedback — so feel free to either email me, or contact me on Twitter @johnsundell. I read every single piece of feedback that I get, and I try to reply to as many people as I possibly can.

Thanks for reading! 🚀