Computer History
The Macintosh's 40th anniversary
The Mac turned 40 just a few days ago, and Steven Levy wrote a piece about it for Wired. It contains quotes from a couple of Apple executes, including Craig Federighi.
The Verge also ran an article to celebrate the the Macintosh's 40th anniversary, including lots of images of the various shapes the Mac took on over the years.
For some light-hearted entertainment, check out iJustine's video of taking her Mac back to Cupertino to see where it came from.
Swift
Case insensitive string comparison in Swift
Natalia explains why converting strings to a common case for comparing them is a bad idea (using the German word “Fußball” / “FUSSBALL” as an example).
The good news is that the Swift SDK includes a function that can properly handle case insensitive comparisons and supports diacritics (such as äéìöüßç and others).
Next time you want to compare two strings, don’t just convert them to lowercase - use the right method instead.
SwiftUI
Using @Binding with @Environment(Object.self)
Trying to bind to a property of an observable object that is stored in the SwiftUI environment? This code will throw a compiler error:
struct WritingView: View {
@Environment(Post.self) private var post: Post
var body: some View {
// ! Compiler Error !
TextField("New post...", text: $post.text) // Cannot find '$post' in scope
}
}
Jordan explains how you can resolve this using two different approaches.
One-way bindings in SwiftUI
Another article about bindings in SwiftUI. Dean walks us through a couple of options for passing one-way bindings to SwiftUI views, from passing simple parameters, over callbacks to using proxy providers.
These are useful techniques to have at your disposal, especially when building reusable components.
SwiftUI Button Styles And Shapes
A quick recap on the many ways to style and shape SwiftUI buttons, including how to create your own custom button style.
Companion for SwiftUI
Timo has been working on this nifty little app that not only includes a bunch of useful resources for learning SwiftUI (videos, newsletters, books, SDKs, and more), but also has code snippets for a number of common use cases - for example a context menu with a preview.
(Full disclosure: I was pleased to see that three of my own resources and the Firebase SDK are included in the app.)
Empty States in iOS 17: A SwiftUI Guide to Keeping Users Engaged
In issue 51, I included Sean Allen's video about ContentUnavailableView. Around the same time, I came across Craig Clayton's excellent video about Empty States in iOS 17. Sean and Craig have very different teaching styles, and I learned a lot from watching both videos. Craig's video covers a few aspects that Sean didn't talk about, so it's definitely worth checking it out.
Productivity
10% More Productive: Mastering the Keyboard
Fun fact: I only learned touch typing a few years ago - previously, I knew quite well where all the keys are located on the keyboard, but I had to look down at my keyboard to actually type. Learning to type without looking at the keyboard has made me a lot more efficient.
In this blog post, the Tower team provide a couple of tips and tricks for becoming even more efficient by learning keyboard shortcuts.
I especially liked the idea of setting up a hyper key - give it a try an let me know what you think!
Business
The quest for killer apps on visionOS
As with all new form factors, it takes a while to figure out what the real killer use case for a new device like the Vision Pro is. Most apps so far just seem to be slightly adopted versions of already existing apps, and most of them use the window metaphor we've been using on desktop computers for the past couple of decades.
Truly immersive or mixed reality apps seem to be an exception.
In this post, John LePore proposes a mixed reality app for Formula 1 races. I am not into F1, but this concept looks very compelling to me, and I think it can be applied to a number of similar use cases (other sports events), and beyond (how about a virtual map that allows you to experience movies in a mixed reality setting - would make movies like Inception quite the ride...)
Tools
Introducing Android emulators, iOS simulators, and other product updates from Project IDX
You might think cloud-based IDE like Project IDX are only useful for backend or web development. In the latest version of Project IDX, you can now run your apps on a native iOS Simulator or an Android Emulator - right in your browser!
This is still an experimental feature, and the team is looking for feedback.
Security
Keep your API keys secure with SwiftOpenAIProxy
Ronald Mannak created a reverse proxy to keep your OpenAI API keys safe. This allows you to ship your app without including your API key in your app's binary. Instead, the API key is set in the environment of the reverse proxy's runtime on the server. Given that it's a lot harder to compromise a server environment, this approach provides a lot more protection against your API key(s) being stolen by malicious actors.
In addition, this package has a couple of nifty additional features, such as being able to verifying App Store subscriptions.
Comment
I've just returned from two weeks of travel to London, Frankfurt, and Berlin for recording videos and meeting with Firebase customers. The goal was to hear from them how they use Firebase, and learn about the challenges they face when using Firebase. If you have feedback for Firebase, there are a couple of ways to share it:
Next week, I will be speaking about Firebase, Gemini, SwiftUI, and Siri at Code Days 2024 in Munich - if you see me, come say hi!
Last week, I called you to send in your suggestions for the new Hidden Gems category, and - boy, did you deliver! Thanks for all the submissions! Some of them actually already were on my regular list of links to include in this issue, so they will appear outside of the Hidden Gems category.
Keep them coming (via this form: bit.ly/not-only-swift-submission), and please let me know how you like the new category (just hit reply and write me an email - I read all your emails, and try to reply to every one of them!
Peter