Coming up

Building a Second Brain App, S2E5: Chat history
After a 2 week pause (I caught a cold), I am back with my weekly livestreams. This week, I'll look into adding history to the Q&A chat, to make chatting with the knowledge base more fun.
Come join me, and bring your questions. Oh - and as mentioned in the intro, I will do another livestream next week where I will look into adding support for Apple Intelligence to the app.
Swift
Migrating to Swift 6
This guide is a useful resource for anyone migrating their code to Swift 6, focusing on Swift concurrency.
The Migration Strategy chapter provides good advice:
Don't panic.
It's worth noting that this guide is under active development - the contributing section lists ways how you can contribute by filing issues or filing PRs to improve existing content or add new content.
New Concurrency Stuff with 6.1
Seems like Swift 6.1 will bring a couple of much-needed updates for Swift concurrency (just the other week I ran into an issue when trying to release a Firebase authentication state listener in a deinitialiser, and I look forward to simplifying my solution once Swift 6.1 becomes generally available.
@MainActor
@Observable
final public class AuthenticationService {
// ...
deinit {
if let handle = authStateHandle {
Auth.auth().removeStateDidChangeListener(handle)
authStateHandle = nil
}
}
private nonisolated(unsafe) var authStateHandle: AuthStateDidChangeListenerHandle? {
willSet {
if let handle = authStateHandle {
Auth.auth().removeStateDidChangeListener(handle)
}
}
}
// ...
}
Thanks to Matt for doing the Lord's work and keeping the community up-to-date on what's happening in Swift concurrency.
SwiftUI
A SwiftUI modifier for inserting the parent UIViewController in the environment
Getting the parent view controller is something you often need for libraries like Google Sign-In, but it's not super straight forward in SwiftUI. This snippet by Harlan Haskins allows you to get the parent view controller from the environment using @Environment(\.parentViewController)
.
However, as Harlan says: "use at your own risk; it's very easy to mess up using this."
SwiftUI Fundamentals - 20% discount
Natalia has just published a new book, “SwiftUI Fundamentals”, which provides a unique insight into how the framework works, giving you a strong foundation to build upon and use SwiftUI more effectively in your projects.
I’ve had the chance to read the book, and can wholeheartedly recommend it!
I’m happy to say that Natalia has agreed to offering a 20% discount for her book to readers of my newsletter. It’s valid for 7 days from the date the newsletter is published, so don’t sleep on this! Use the following code at checkout NOTONLYSWIFT73XRB, or use this link.
AI and ML
Ollama
Ollama is the easiest way to run large language models on your Mac. You can think of it as “Docker for LLMs” - a way to pull, run, and manage AI models as easily as containers.
This is a brilliant way to explain Ollama. In the rest of the article, Mattt walks through how to call Ollama from macOS apps using the Ollama client SDK he built.
I love that he even includes a Swift implementation of cosine similarity search.
Being able to run LLMs locally opens the doors for many use cases, even if frontier models like GPT-4, Claude, Llama, and Gemini can generate more tokens per second than local models.
Exploring MLX Swift: Getting Started with Tool Use
Tool use (or tool calling) allows LLMs to invoke code in your app to perform additional work. Typical examples include getting the local weather, calling currency conversion APIs, and retrieving data from local data sources.
Rudrank shows how to do this with MLX and Swift. If you're curious how to do this in Genkit, check out my expense tracker sample.
Preparing Your App for Apple Intelligence: My Conference Talk from NSSpain 2024
In this talk, Matt (who used to work on Workflow, the app that was acquired by Apple and then became Shortcuts) explains why anything your app does should be an App Intent.
The talk focussed very much on design and architecture, and Matt does a really good job at explaining Apple's guidelines for App Intents and Siri Shortcuts.
Applied AI Software Engineering: RAG
For folks who are interested in what RAG is and how it works. This is what we’re using in Sofia, so if you're gollowing along my Building a Second Brain App livestreams, this is useful background information.
Tools
DeskPad: A virtual monitor for screen sharing
When sharing your screen to a video conference or on a livestream, you want to be sure you're not accidentally sharing parts of your screen that show your script or other sensitive information.
DeskPad creates a virtual screen that shows up just like any other display in the macOS display settings. In addition, you get a projector window that shows the contents of the virtual display.
What sounds complicated is actually super useful when running livestreams. I've been using this for the past couple of months to run my Building a Second Brain App livestreams, and couldn't be happier.
One more thing...
Apple Silicon Inside Stickers
If you've seen any of my talks, you know that I am #teamstickers. So you won't be surprised that these stickers werean insta-buy for me. Can't wait to install them - I'll report back how they look in real life!
A few days ago, Apple officially announced Apple Intelligence will expand to more languages and regions in April, giving users in the EU access to Apple Intelligence features "for the first time" (well, not strictly true - at least if you were willing to jump through a couple of hoops).
If you're brave enough to upgrade to iOS 18.4 beta, you will get access without having to make any further changes.
So, it's time to get your apps ready for Apple Intelligence and make use of the new features it brings. I'm excited to participate in the "Enhance your apps with Apple Intelligence and App Intents" event this week, and I plan to talk about what I learned in one of my next livestreams, and discuss how you can mix and match different AI providers (such as Apple Intelligence and Gemini / Genkit).
To get started, I've included Matt Cassinelli's NSSpain 2024 talk, which provides some really valuable design considerations.
Now, the real question is, will Siri become smarter and more useful with Apple Intelligence? We'll find out once a significant number of apps support Apple Intelligence features, so it's in our hands to a certain extend!
Peter