Snapp Mobile iOS Newsletter

Issue 5 • August 30, 2024

Swift

Mastering Observation framework in Swift

Apple introduced the new Observation framework powered by the macro feature of the Swift language. The new Observation framework, in combination with the Swift Concurrency features, allows us to replace the Combine framework that looks deprecated by Apple. This week, we will learn how to use the Observation framework to handle data flow in our apps.

Migrating from the Observable Object protocol to the Observable macro

Here’s Apple with a dedicated documentation page and a sample app to help us transition from using ObservableObject towards adopting the @Observable macro.

What are Swift Concurrency’s task local values?

Swift Concurrency allows us to use something calles “task local values”. It’s a feature that often gets overlooked but is actually the recommended way to do depencency injection when concurrency is involved. Donny Wals takes a look and explains what it takes to create task locals and how to use them.

Multiplatform

Kotlin Flow to Swift Combine: A KMP Bridge. Part I

Our colleague Volodymyr Voiko has been on a roll these days. Here’s the first of his series of articles where he looks at bridging Kotlin Flow with Combine Publisher. Examined are the limitations of Kotlin to Objective-C/Swift interoperability and there’s a discussion on the issues that may arise.

Kotlin Flow to Swift Combine: A KMP Bridge. Part II

In this part our Volodymyr Voiko looks at a potential solution to the the limitations of Kotlin to Objective-C/Swift interoperability. What he came up with is not only neat, technically, but very pragmatical, we promise!

Skip 1.0 Release

Skip brings Swift app development to Android. Share Swift business logic, or write entire cross-platform apps in SwiftUI. It is the only tool that enables you to develop genuinely native apps for both major mobile platforms with a single codebase. Under the hood, it uses the vendor-recommended technologies on each OS: Swift and SwiftUI on iOS, Kotlin and Compose on Android. So your apps don’t just “look native”, they are native, with no additional resource-hogging runtime and no uncanny-valley UI replicas.

UI

Using @Observable in SwiftUI views

Natalia Panferova wrote a post on integrating Observable with SwiftUI for providing data to views. It covers passing it through the environment, creating bindings to its properties, and compares it to ObservableObject with Published properties. As iOS 18 approaches and we might consider dropping support for versions below iOS 17 soon, now may be a great time to explore how we can use Observation in our SwiftUI projects.

Utils

swift-perception

The Perception library provides tools that mimic @Observable and withObservationTracking in Swift 5.9, but they are backported to work all the way back to iOS 13, macOS 10.15, tvOS 13 and watchOS 6. This means you can start taking advantage of Swift 5.9’s observation tools today, even if you can’t drop support for older Apple platforms.