Computer History
Thanksgiving Feast for the Mind: The Core of Apple’s Hardware Engineering
Did you ever wonder which stages a hardware product goes through before it hits the shelves? In this post, Michael Darius explains what EVT, PVT, and MP are, and shows some rare behind-the-scenes prototype sketches and images of stacks of Apple devices in various stages of their pre-production life.
Swift
Gosh Darn Format Style!
Swift’s FormatStyle
and ParseableFormatStyle
are the easiest way to convert Foundation data types to and from localized strings. Unfortunately Apple hasn’t done a great job in documenting just what it can do, or how to use them. This site aims to solve this problem, and it does a pretty good job at it.
I was reminded of Gosh Darn - if case let, and Gosh Darn - Swift closures, and wanted to include an entire list of all the Gosh Darn sites - but it turns out someone else has already done the work: goshdarnsyntaxsite.com
Create an AsyncStream from withObservationTracking() function
In this article, Matthaus Woolard takes Natalia's example from last week, and shows how to wrap a stream of Observation events into an AsyncStream
. I love how this makes the code a lot more readable at the call site.
What I find striking is that code that makes use of AsyncStream
is very similar to code that makes use of callbacks. For example, here is a code snippet that shows how to listen to changes in a Firestore collection:
let listener = Firestore.firestore().collection("fruits").addSnapshotListener { querySnapshot, error in
guard let documents = querySnapshot?.documents else { return }
self.fruits = documents.compactMap { queryDocumentSnapshot in
do {
return try queryDocumentSnapshot.data(as: Fruit.self)
}
catch {
return nil
}
}
}
And here is how this looks like when using an AsyncSequence
:
let fruitsSequence = Firestore.firestore().collection("fruits").snapshotSequence(Fruit.self)
for try await fruits in fruitsSequence {
self.fruits = fruits
}
This code is based on a prototypical implementation of AsyncSequence
in Firebase. Let me know what you think (e.g. by leaving a comment on the PR, or by replying to this email) - would you like to use this?
How to import Swift macros without using Swift Package Manager
Swift Macros are one of the hottest new features in Swift - check out Swift-Macros (curated by Krzysztof Zabłocki), which has an extensive list of macros that are publicly available.
Macros are usually defined in Swift Packages, and are shipped as source code. But what if you don't want to use Swift Package Manager, or if you don't want to ship your macros as source code?
Pol Piella has you covered - in this article, he shows how to compile a macros in to a binary, and then import it into a build target. Pretty cool!
SwiftUI
Open Source Animations for SwiftUI - Pow!
If you're looking for an excellent library with some classic animations such as Glare, Glow, Iris, or Swoosh, don't look any further - Pow has them all. It also has some more playful ones, like Spray and Smoke. And of course, no animation library is complete without Anvil...!
I first came across Pow when I was looking for a playful animation for a like / star icon, and Pow's Pop, Rise, and Spray add just the perfect level of playfulness.
The Moving Parts team have just open sourced the library together with Emerge Tools, so now is the perfect time to add some delight to your app. Besides being a fantastic animations library, the source code is a great learning resource - after all, this are the same folks that brought you Styling Components in SwiftUI, and Composable Styles in SwiftUI!
Security
Using on-demand resources for securely storing API keys in iOS apps
With the rise of LLMs-powered services (which can get quite costly when used at scale), securing your API keys has become more and more important.
In this article, Toomas Vahter looks into one possible approach for preventing attackers from exfiltrating your API from your app's binary: on-demand resources.
This is a great approach to keep anyone from stealing your API key by analyzing your app's binary, but it doesn't prevent an attacker from performing a man-in-the-middle attack.
To protect your app against these kinds of attacks, you can use tools like App Check, which ensure that only your legitimate app can call your API endpoints.
Podcasts
Land of the Giants: The Twitter Fantasy
I really enjoyed this season of Land of the Giants about Twitter, hosted by Peter Kafka. It "aired" exactly one year after Elon Musk took over in what was the history's most expensive impulse purchase, and covers the social and political implications of this change of ownership. I've been on Twitter since 2009, and found it very interesting to revisit some of the early ways users made Twitter their own by inventing hashtags and RTs in episode 2 - A Million Different Twitters.
Definitely worth a listen if you're on Twitter, or are considering leaving the platform.
Fun stuff
"Please be a C++ GUI programming guide"
The Get a Mac ad campaign is a masterpiece of advertising, and it's still fun to watch after all these years.
Comment
This week, I will be at the Copenhagen Swift & Cocoa meetup at the Google office in Copenhagen. It's a while since I've last been in Copenhagen, and I look forward to eating delicious Kanelsnegle and connecting with the local developer community (we've got more than 100 sign-ups).
If you attend the event and are a reader of my newsletter, come and say hi!
In other news, I am busy editing a couple of videos we shot earlier this year, and if things go well, they will the Firebase YouTube channel before Christmas.
But what keeps me really busy is [redacted], and I can't wait to share it with you once it's launched. I will probably talk about it more next year, for example at Code Days 2024.
Peter