6 min read

Issue #79: defer Done Right, Instruments is Back, and WWDC Is One Week Away

Hey everyone! πŸ‘‹

Welcome back. WWDC is seven days out, Apple dropped 36 Design Award finalists, Point-Free shipped a library that finally solves testing @Observable classes, SwiftLee made the case that your concurrency code needs a date with Instruments, and Majid reminded us all that defer is genuinely underrated. Let's get into it. πŸš€


defer: Your Cleanup Crew

You probably know defer exists. You probably use it occasionally. Majid's latest piece makes the case that you're not using it enough, and shows the patterns where it really shines.

The most compelling example is HealthKit's observation API, which requires you to call a completion handler after you finish processing. With defer, you declare the cleanup right next to the setup, so it can't get lost in a branchy function:

for await handler in await health.observe(types: [...]) {
    defer { handler() }
    if handler.types.contains(HKQuantityType.heartRate) {
        await processHeartRate()
    }
}

No matter how many branches your logic grows, handler() always fires when the scope exits. The defer keyword is the right tool any time you acquire a lock, create a temporary resource, change some state that needs undoing, or receive a completion handler that must be called later.

Swift Defer. Clean up before you leave.
You may think about defer keyword as one of the most ambiguous language features in Swift, but it is very useful in some cases. You can use it deliberately, and it will give you safety. This week we will talk about some best practices of using defer in Swift.

Deprecating Your Own Convenience API (Gracefully)

This one from Majid two weeks ago is a keeper for teams supporting iOS 26 and 18 simultaneously. The pattern: write your compatibility shim for the old platform, then use @available with obsoleted: to mark it for future removal.

extension LabelStyle where Self == ToolbarLabelStyle {
    @available(iOS, obsoleted: 26, message: "You don't need .toolbar anymore")
    static var toolbar: Self { .init() }
}

When you bump your minimum target to iOS 26, the compiler flags every usage. When you eventually hit iOS 27 support, it becomes an error. You get staged deprecations with zero extra tooling, just the compiler working for you.

Deprecating your own convenience API
Almost after every major update of iOS, we got new APIs that we use on the most recent platform but can’t use on the previous one. Usually, I solve this kind of thing by introducing my own convenience code that runs new APIs on the available versions and my custom implementation or stubs on old platform versions.

Instruments Is Your AI Code Reviewer

Antoine van der Lee (SwiftLee) dropped a timely reminder this week: agentic development quietly reintroduces the performance risks that faster devices had mostly papered over. AI-generated code can look perfectly correct and still perform terribly at runtime, and Xcode Instruments is exactly the tool to catch it.

The piece walks through the Swift Concurrency template specifically: how to read the thread pool utilization, spot unexpected suspension points, and understand when tasks are competing in ways the compiler can't see. If you've written off Instruments as something you only need when things are obviously broken, this is a good reread. The argument is that with agentic workflows, you should be running it proactively.

Using Xcode Instruments to optimize Swift Concurrency Code
Explore how Xcode Instruments can help you analyze, debug, and optimize your code for better app performance.

Tanaschita: Animations and Keychain

Two more posts worth bookmarking from Tanaschita this fortnight.

SwiftUI animations basics (May 17): A clean reference piece covering withAnimation, implicit vs. explicit animations, and the .animation(_:value:) modifier. Great to forward to teammates who are still doing this from memory.

Keychain in iOS (May 25): A thorough guide to SecItemAdd, SecItemCopyMatching, and SecItemUpdate wrapped in a clean Swift interface. Covers access control flags and when to use kSecAttrAccessibleAfterFirstUnlock vs. the stricter options. With WWDC a week away and on-device AI storing more sensitive data, this is well-timed.

Understanding basic animations in SwiftUI
Learn different options to animate SwiftUI views in your iOS applications. Understand the two animation options animation(_:value:) view modifier and the withAnimation(_:_:) global function.

Point-Free: Testing @Observable Classes Just Got Fixed

Point-Free's DebugSnapshots graduated to public beta this week. The problem it solves: @Observable classes can't be meaningfully made Equatable, which has always made exhaustive state testing awkward. DebugSnapshots works around this with a macro:

@DebugSnapshot
@Observable
class CounterModel {
    var count = 0
}

The @DebugSnapshot macro generates a value-type snapshot of the class's data. You can then assert on how that state changes across operations β€” the same exhaustive "before and after" testing that was previously only practical with value types.

This is also the foundation for ComposableArchitecture 2.0's TestStore, which is still in beta but uses DebugSnapshots under the hood to eliminate the need for State: Equatable in tests.


Apple Design Award Finalists Are Out

With WWDC on June 8, Apple announced its 2026 Apple Design Awards finalists. 36 finalists are competing across six categories, with three apps and three games in each. Some titles appear in multiple categories, including Tide Guide: Charts & Tables, TR-49, and Sago Mini Jinja's Garden. MacRumors + 2

Apple Design Award Finalists Announced Ahead of WWDC 2026
In preparation for the 2026 Worldwide Developers Conference that is set to begin on June 8, Apple today announced its finalists for the 2026 Apple Design Awards. Apple picks top apps and games annually, and announces winners at WWDC. The Apple Design Awards recognize apps with innovation, ingenuity, and technical achievement in app and game design.

Triple-A titles like Cyberpunk 2077 and Civilization VII are among the games nominated. visionOS titles like Pickle Pro and D-Day: The Camera Soldier still have a chance of winning, despite Apple no longer having a dedicated Spatial Computing category. AppleInsiderTUAW

Apple Design Awards 2026 Finalists Revealed
Apple has unveiled the finalists for its 2026 Apple Design Awards, putting a spotlight on some of the most creative apps and games in its ecosystem. The

Winners will be announced during WWDC 2026, with each winning team receiving a physical award and hardware support for future development. Worth spending ten minutes browsing the finalists, there's good inspiration in there for how teams are using Apple technologies right now. The Mac Observer


One Week Out: WWDC 2026

June 8–12. Foundation Models 2.0, iOS 27, deeper Xcode agent integration. The community pregame content is ramping, Matt Massicotte published his WWDC watch list, Swiftjective-C dropped a pregame quiz, and the buzz around what Apple Intelligence's second year looks like is at a peak. Get your apps tested, your betas filed, and your conference playlist ready.

That's Issue #79! defer is underused, Instruments is essential again, and @Observable testing finally has a clean answer. See you on the other side of the keynote. πŸš€