2 min read

Issue #7

Hi there,

Happy Xcode RC week! The release notes are extensive, but nonetheless are worth checking at some point, because there are many small improvements that are not mentioned anywhere else. I'll be going through the changelog myself, and will post anything that can improve our code 🙌

Let's dive in 👇

Crash in Combine

It's almost a tradition now to start the newsletter with a tip about an obscure Combine issue... This time, it turned out that breakpointOnError() crashes apps. To solve this, you can make an extension that conditionally uses this only if debugger is attached. But I just comment it out completely when not debugging 😅

SwiftUI + Combine = 🧡

SwiftUI's onReceive opens some really interesting possibilities. Here's @danielsaidi with an example showcasing the power of SwiftUI when you sprinkle extra Combine on top. This code subscribes to a data binding of a UI element (a form in this case) and pipes changes into a save function. Makes the UI code really concise and pretty hard to break.

Swift API design guidelines

Saw a tweet the other day, a person saying that they wish Swift had an official API guideline. So a refresher just in case - it does! Makes you a pro at writing function signatures that feel right at home in Swift.

Swift.org - API Design Guidelines

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

Lazy local variables

Starting with Swift 5.5 (shipped with Xcode 13), we can use the lazy keyword on local variables. Code that had to use closures to achieve this lazy behaviour can now be simplified 🎉

Code example from the release notes

Time-based git diffs

Git supports a bunch of ways to reference commits (revisions): by commit hash (full or short), branch name, HEAD~n to jump back n commits, etc. Apparently you can not only reference commits, but also reference a specific moment in time. Thanks to @trevorbrindlejs for sharing this.

If you want to learn about all the ways to reference revisions, check the documentation.


Alright, that’s it for today.

Did you enjoy this issue? Let me know by pressing the buttons below, so I can improve the newsletter.

Got feedback? Want to see more, or less of certain kinds of tips? I’d love to hear from you. Reply to this email or reach out on Twitter via @ios_code_review 🙌