promotion
Powerful debugging in Xcode,
no code changes or 3rd party frameworks required.

Bridge from Combine to AsyncSequence - the plan (p. 1)

Previously, I wrote about actors in Actors part 1 and Actors part 2; this time I’m going to cover how to write a Combine operator to proxy a Combine publisher into an async sequence that you can iterate over by using a simple for loop. Note: The current version of Xcode 13 is beta 2 and I’m going to be using the latest swift.org toolchain nightly snapshot in order to make use of AsyncStream. …

Posted on

Swift Actors: A practical example, part 2

In my previous post Swift Actors: A practical example, part 1 I covered how I got a Swift.org toolchain from trunk, enabled support for the currently experimental support for structured concurrency, and created a thread-safe cache in few lines of Swift code. If you missed part 1, definitely do read it first as this post builds upon the code I already covered there. » When I wrapped up writing part 1, I was looking at my new cache actor and I started wondering “What about Combine? …

Posted on

Swift Actors: A practical example, part 1

I’ve been re-reading the Swift structured concurrency roadmap and the Swift actors proposal and noticed a note on the latter saying: “Partially available in recent main snapshots behind the flag -Xfrontend -enable-experimental-concurrency” So, naturally 🤓, I downloaded the latest snapshot from Swift.org and took it for a spin to try out some actor code! Installing Swift toolchain with actors support Huge disclaimer: this is all experimental experience using a trunk code not cut into a release. …

Posted on

Using self, weak, and unowned in Combine

Updated with more examples on Mar 6th, 2021. One of the most often asked questions in the Combine and RxSwift slack channels is something along the lines of: Should I use self, weak, or unowned with my reactive code? Given that most operators take closures, it’s a fair question. In this post I’ll go over common scenarios for using weak, unowned or simply self and include links with more information at the bottom. …

Posted on

Owning AnyCancellable with Cancellor

Swift 5.4 officially introduces @resultBuilder, which is a way to create custom DSLs and generally create more semantic APIs (think of the way you write SwiftUI today). I wanted to play with it and create something useful for Combine developers so I thought “Would it not be handy to batch-add publisher subscriptions to an owned list of cancellables?”. I remembered back in the day I used an extension on NSObject that adds automatically a dispose bag to all objects in case you need one created by Ash Furrow and I thought I’d put together something in the same fashion. …

Posted on

5 Stranger Things you can do with Timelane at NSSpain

For my talk at NSSpain 2020 I’ve prepared a beyond-the-basics Timelane talk. I think everyone who’s heard about Timelane by now knows what it does for its simplest use case - debugging some Combine based code. However, you can do much, much more with Timelane! So for my NSSpain 2020 talk I prepared 5 little examples on how to use Timelane beyond the simplest use case. I’ve pushed all the demo apps I use in my talk to this repository: https://github. …

Posted on

How to create a custom instrument on top of Timelane!

You can easily log data in Instruments by using the functions in Apple’s os framework. All you need is to use os_log(…) and that will log data in Instruments. If you’d like to read more about this check out Recording Performance Data Apple article. Creating a real custom instrument, however, is a little more complicated as you can learn in Creating Custom Instruments WWDC2018 video and it involves XML, CLIPS, and more complex stuff. …

Posted on

Timelane - the first two weeks!

It’s been two weeks since I released Timelane and I’m really humbled by the community’s super positive response. Since much has happened since the launch, I’m writing this to give everyone a detailed update. The current versions are as follows: TimelaneCombine 1.0.4 RxTimelane 1.0.3 TimelaneCore 1.0.3 I’ve merged 18 PRs (in the 14 days since launch!) on all Timelane repos and I pushed some changes myself too. Here’s a summary of what’s new. …

Posted on

Announcing: Timelane

Today I’m announcing the public release of Timelane. Timelane is a free, open source Instrument that helps you profile and debug asynchronous code. Timelane is available today on: http://timelane.tools. The Timelane Instrument leverages signpost logging and the powerful Instruments UI to help you visually inspect asynchronous subscriptions and drill down through logged events over time. Installation Install the latest build from http://timelane.tools or fork the repository on GitHub and build the app yourself. …

Posted on

Property Wrappers with Combine

In this post I’ll look into making more out of Combine code by using the newly introduced in Swift 5.1: Property Wrappers. Let’s very quickly go into what property wrappers are in general and then dive into a Combine example. Swift Property Wrappers Property wrappers are a new feature in Swift 5.1 that allows you to abstract redundant functionality around handling type properties. Property wrappers are very handy in (my experience so far 🤓 ) two ways: …

Posted on