My favorite books 2020
Dec 31, 2020, 11:18 AM
I read 45 books in 2020. These were my favorites. (Thinking in SwiftUI was not in the running because I’m biased.)
The Age of Surveillance Capitalism by Shoshana Zuboff (2019). If you pick up one book from this list, make it this...
Thinking in SwiftUI
Dec 19, 2020, 10:33 AM
Chris and Florian’s new book Thinking in SwiftUI came out in March 2020 already, so I’m late to the party with this announcement. But I still want to mention it here because (a) it’s a good book and (b) I had a small...
Where is end-to-end encryption for iCloud?
Dec 10, 2020, 11:17 AM
In a December 2020 video recorded for the European Data Protection & Privacy Conference, Apple’s Craig Federighi touts end-to-end-encryption for iMessage (starting at 55:36):
iPhone users don’t have to worry their private...
as, as?, and as!
Jun 29, 2020, 2:11 PM
In Debugging Generics in Swift, Joshua Emmons touches on a tricky area in Swift: the difference between as, as?, and as!.
Consider the following, simplified example from Joshua’s article. The second line traps with a runtime error:
4 as...
Sanitizing GPX files for public sharing
Jun 22, 2020, 10:01 AM
GPX is a popular XML format for running or cycling tracks with geocoordinates. This is a how-to for cleaning up a GPX file by removing unwanted or privacy-sensitive information.
What’s in a GPX file?
Many apps that record workout routes...
Linking to text fragments in web pages
Jun 21, 2020, 5:07 PM
Text fragments are a way for web links to specify a word or phrase a browser should highlight on the destination page. Google Chrome added support for them in version 80 (released in February 2020).
For example, opening the link...
Testing UIKit accessibility in unit tests
Apr 30, 2020, 12:29 PM
I’m writing a custom progress view in UIKit:
My circular progress view
One of the design goals for the view is to be a drop-in replacement for UIProgressView. This means it should model UIProgressView’s...
Testing Swift packages on Linux using Docker
Feb 2, 2020, 1:44 PM
You are on a Mac and want to run or test one of your SwiftPM packages on Linux? Here’s how, using Docker.
Running the Docker container
First, download, install, and run Docker Desktop for Mac.
In Terminal, switch to the directory of the...
Automatic test discovery in Swift on Linux
Feb 2, 2020, 1:43 PM
In 2017, I wrote an article titled Keeping XCTest in sync on Linux. In it, I proposed to add some code to your test classes that would alert you when you forget to update the allTests array after adding a test method.
Swift 5.1 ships with...
Sheets don’t inherit the environment
Jan 23, 2020, 12:36 PM
This behavior has been fixed. As of Xcode 12.0 (the iOS 14.0/macOS 11.0 SDKs), sheets do inherit their environment.
Unlike other views, modal sheets in SwiftUI do not inherit the environment from their parent.
What is the...
Enumerating elements in ForEach
Jan 17, 2020, 11:45 AM
Suppose we want to display the contents of an array in a SwiftUI list. We can do this with ForEach:
struct PeopleList: View {
var people: [Person]
var body: some View {
List {
ForEach(people) { person in
...
TopLevelEncoder and TopLevelDecoder in Combine
Jan 7, 2020, 7:08 PM
Speaking of the Combine framework, I find it interesting that Combine had to introduce a formal concept for top-level decoders in order to implement its decode and encode operators. These operators use Swift’s Codable system to...
URLSession.DataTaskPublisher’s failure type
Jan 7, 2020, 12:47 PM
In March 2018, I wrote a piece titled Making illegal states unrepresentable, in which I argue that the “correct” result type for URLSession completion handlers is Result<(Data, URLResponse), (Error, URLResponse?)>.
In other...
My favorite books 2019
Dec 30, 2019, 9:52 AM
Listed in the order I read them. Some are in German, some in English, but you should be able to find translations for most of them. No tech book made the list this year (I didn’t finish any).
I enjoyed quite a few comics and graphic...
Advanced Swift, fourth edition
May 31, 2019, 1:04 PM
The fourth edition of our book Advanced Swift is available now.
If you bought a previous edition of the e-book, this is a free update for you.
Advanced Swift is the book for people who have read The Swift...
Chris Lattner on the origins of Swift
Feb 18, 2019, 11:13 AM
In episode 1 of the new Swift Community Podcast, Chris Lattner, Garric Nahapetian, and John Sundell spoke about the origins of Swift and the current state of the Swift community, among other things.
This is a transcript (edited for...
My favorite books 2018
Dec 27, 2018, 3:12 PM
Listed in the order I read them. The list includes some fiction, some non-fiction. Few tech books. Some are in English, some in German. Some on serious topics, some light entertainmen, one children’s book, and one photo book.
...
Small Fry
Nov 30, 2018, 1:30 PM
Small Fry, the memoir of Lisa Brennan-Jobs, is one of the best books I’ve read this year. Lisa tells the heartbreaking story of growing up in Silicon Valley, her loyalties split (and often torn) between her mother and...
Splitting a Swift Sequence into head and tail
Nov 29, 2018, 5:57 PM
A common pattern in functional programming languages is to split a list into its head (the first element) and tail (all remaining elements). For example, in Haskell, the pattern x:xs matches against a non-empty list and binds the list’s...
Roy Fielding’s REST dissertation
Oct 31, 2018, 6:49 PM
I recently read Roy Fielding’s 2000 PhD thesis, Architectural Styles and the Design of Network-based Software Architectures, in which he introduced and described REST. Here’s what I learned.
REST is almost as old as the web. I first heard...
PhotoKit’s data model
Sep 28, 2018, 11:36 AM
Apple’s Photos.framework, which powers the iOS Photos app and gives developers access to the device’s photo library, uses Core Data under the hood.
You can confirm this in at least two places:
Write an app that accesses the photo...
It’s wrappers all the way down
Sep 25, 2018, 2:09 PM
Suppose we have a string that ends in a specific pattern, like this one:
let str = "abc,def,…[many fields]…,1234"
We want to extract the last field, i.e. the substring after the last comma, i.e. "1234".
Splitting the entire string
One...
The 2018 Macbook Pro
Sep 7, 2018, 10:59 AM
I’ve been using a new 2018 MacBook Pro as my primary work machine for a few weeks now. I bought the top configration: 2.9 GHz six-core i9 CPU, 32 GB RAM, Radeon Pro 560X GPU.
My previous computer was a Late 2013 MacBook Pro with a 2.6 GHz...