Snapp Mobile iOS Newsletter

Issue 9 • September 27, 2024

Welcome to another edition of the Snapp Mobile iOS Newsletter!

This week we’re focusing on the UI/UX side of things and we have some treats for your UIKit projects. We’re also taking a look under the hood of SwiftData’s deletion mechanisms and we’re checking on an improvement to Swift’s ISO 8601 date formatter.

Enjoy!

Swift

Power of Swift Macros

Working on UIKit-only projects does not mean you should miss on some of the timesavers Xcode has to offer. And yes - we mean previews first and foremost. As useful as they are, previews are mostly used with SwiftUI as in order to use it with UIKit views you have to write some repetitive code - mainly wrapping your UIView in UIViewRepresentable. Here’s how to avoid writing all that boilerplate with the help of Swift Macros.

How to keep Date’s microseconds precision in Swift

Dealing with different String representations of a Date can be quite challenging in some cases. It does not help that the default iOS DateFormatter is not tailored for supporting precision at microsecond granularity but, as usual, there are ways to fill in the gap as Toomas Vahter discovered.

UI

Animating number changes in SwiftUI

We love these on-point articles from Sarun W. Sometimes what a view composition needs is a neat animation to highlight a value change. Apple is using a neat numbers animation across their widgeting system and this article shows you how to apply that very same animation on any SwiftUI text view that contains numbers.

How to Use SwiftData in UIKit Apps

While SwiftUI gets more of the hype these days, UIKit is still around and still faces updates with each iOS version. This article looks at how to integrate the SwiftData framework, new from iOS 17, with UIKit. Enjoy!

Mastering MapKit in SwiftUI. Interactions.

To highlight the statement above - here’s an example of interacting with MapKit from SwiftUI. This article looks at some useful additions to track the map camera changes and to animate them using keyframes. It’s always the micro-interactions that make for a good app.

Integrating Haptic Feedback In SwiftUI Projects

This is more of a UX topic, but adding feedback to your apps can vastly improve the user interaction in many places across your apps. Haptics can be used to complement an action feedback like “rewarding” the user on success or complementing an failure message. There are cases where a haptic, along with a nice animation, may be all that’s needed to make a difference and here’s how to get started.

Insetting Scrollable Views’ Content With contentMargins In SwiftUI

With iOS 18 now public, some app developers may consider dropping support for iOS 16. This opens the door to adopting some SwiftUI improvements and additions, introduced with iOS 17. One such addition is the contentMargins view modifier that allows you to fine tune the insets of a ScrollView content.

SwiftData

SwiftData Deleting Data

This article looks at a few ways to delete data from SwiftData. As the framework is relatively new (from iOS 17) it’s helpful to gather knowledge around the differences and the improvements it adds over CoreData.