Firebase
How to Use Firebase Queues
For some types of applications, you need to perform a specific task on a recurring basis, independently of the user.
Queues are a great way to do this - they allow you to offload parts of your application and schedule work to run asynchronously in the future.
In this blog post, the Ayrshare team explains how they used Cloud Tasks to implement queues on top of Firestore. Their use case (sending scheduled social media posts) reflects a typical use case: running a workload in the future. Another good use case for queues is any task that takes longer to complete than the user is willing to wait for. Offload the task to a queue, and notify the user once it has finished.
Swift
Speeding up Swift Macros
In this article series, Ruslan shows how he analysed the reason why adding Swift macros can slow down the compilation time of your apps (spoiler: it's got to do with swift-syntax
).
The good news is that Ruslan filed a PR that fixes some of the performance issues, and the even better news is that it got merged!
In the second part of the series, Ruslan dives even deeper into strategies for optimising type checking performance for swift-syntax
- including a PR (still pending at the time of this writing).
SwiftUI
@Observable Macro performance increase over ObservableObject
Antoine looks at how to migrate from ObservableObject
and @Published
to Apple's new Observation framework.
Using the @Observable
macro improves the performance of SwiftUI views by preventing unnecessary redraws, and makes your code easier to read - what's not to like(*)?
(*) yeah, I know - this is only available from iOS 17 / macOS 14 onwards...
AnyView’s impact on SwiftUI performance – martinmitrevski
You might have heard that using AnyView
is bad for the performance of your SwiftUI views, in particular if they are inside a List
view.
There is an excellent WWDC talk about this: Demystify SwiftUI - if you haven't watched it yet, set aside some time to do so, it's really good.
In this blog post, Martin Mitrevski dives deeper into the reasons, and provides some test results.
The TL;DR: is : Don’t use AnyView
- if you are in a loop! If you only need to display a handful of menu items in a List
, using AnyView
is acceptable.
Productivity
Tom Scott, and the formidable power of escalating streaks
So, the year 2024 is officially more than a week old, and chances are that a good chunk of all the New Year's Resolutions have already been dropped.
If you are looking for some inspiration for why it pays off to not give up on a streak, and where you might end up if you improve only a tiny bit every day, week, month - check out Tom's final video.
What inspired me the most about Tom is the apparently insatiable curiosity with which he looks at the world. What a run!
Business
Displaying an app install button on Twitter
Twitter has a bunch of somewhat obscure features, such as adding a direct message button to a tweet:
https://twitter.com/messages/compose?text=example%20text&recipient_id={your numerical Twitter ID}
But did you know that you can also display an install button for your app? All you need to do is to add some meta data to your app's landing page.
@Amani_Art shows how (and there's also a handy link to their app to try this out) in this thread.
Tools
Excalidraw
If you need a tool to quickly draw a diagram, definitely check out Excalidraw. It supports the basic shapes and connectors for quickly sketching an architecture diagram, allows embedding images and even web embeds. It also has a nice integration with Mermaid, allowing you to convert flowcharts, sequence diagrams, and class diagrams into beautiful, faux hand-drawn diagrams.
And of course, there is an AI-powered text-to-diagram feature.
Maybe the most impressive feature is its real-time white-boarding capability: by just sharing a link to your current diagram, you can work on it collaboratively with a team mate or friend. Really amazing.
I heard about this in the (German) programmier.bar podcast - thanks for sharing, Sebi and Fabi!
Podcasts
The Untold Story of SQLite
SQLite is among the most widely deployed pieces of software: among the many well-known users of SQLite are operating systems (iOS, Android), web browsers (Chrome, Firefox), car entertainment systems, and even the A350 XWB flight software!
In this episode of CoRecursive, host Adam Gordon Bell interviews Richard Hipp about the unlikely story of how SQLite was created over Richard's frustrations about the Informix database system. This is one of the most amazing stories I've heard about software development, and if you think building an embedded database from scratch is quite the feat, wait until you meet the person who also built their own custom parser generator, and a bespoke version control software to be independent.
If you're more of a reader than a listener, the episode page has a full transcript!
Before you go...
Discount code for Asynchronous Programming with SwiftUI and Combine
If you've been trying to use the discount code from the welcome message to my newsletter, and it didn't work - I'm really sorry about that!
It turns out that the code expired.
The good news is that there is a new code which gives you 20% off of either the paper book or the eBook, and it is SwiftUI24. On my blog, click on the the "Buy the eBook or softcover on Springer" link, and enter it at check out.
Also, if you already bought the paper book, you can get the eBook for just 5 USD using this link
Comment
This episode of Not only Swift is all about performance - I've included two articles that look at improving the performance of your SwiftUI code, and one about why adding Swift macros might deteriorate the compilation time of your project.
In the previous episode, I mentioned that I am opening up the newsletter for reader submissions, and I am super happy to say that we've got the first Hidden Gem in this episode! If you'd like to contribute, use this form - I look forward to hearing about all those cool and fun projects that I might have missed myself.
I will be in London next week (to record some videos for Gemini - one of them will be about how to use the Swift SDK for Gemini to build a chat-driven text adventure like this one.
If you'd like to meet up over coffee or for lunch at the Google office at King's Cross, book a slot on my calendar.
Enjoy reading this issue!
Peter