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

Optimization in Swift, part 2

In Part 1 I wrote what this mini-series would be all about. Given the default array filtering is a performance bottleneck for my fictional app, I’m going to explore if I can write code that performs better in my specific use case. In this part, I’m going to rewrite my initial filtering function and use the new async/await Swift concurrency syntax. An async filter function Since TaskGroup still has a performance issue in the current version of Swift, I’ll use a simplified code that uses only top tasks (e. …

Posted on

Optimization in Swift, part 1

This will be yet another exploratory series on my blog — this time around, I want to write a little about optimizing performance in Swift code. This is, of course, an endless topic so what I’m going to do is, similarly to previous posts, focus on a problem and then track my way through working on it. Also, since this might turn into a somewhat longer read, I thought I’d split it into several short parts; so if you are in fact interested to read through you don’t have to put in all the time at once. …

Posted on

TaskGroup as a workflow design tool

For my talk at iOS Conf SG 2022 I wanted to showcase some Swift concurrency use-cases that don’t fall into the common scenarios. Revisiting the slides some weeks later, I think it’d be fun to cover my TaskGroup example in more detail. In this post I’ll show how to use TaskGroup to design a complete (but fictional) user login-sequence. What is TaskGroup good for? Most examples floating around show using a TaskGroup to add a number of identical tasks to a group and execute them concurrently. …

Posted on

The issue with task groups or how I discovered a solved problem

This post is not my usual format but there is a moral at the end, so hang around if you have a little time to waste. The setup I’m working on a longer blog post about the process of optimizing some concurrency Swift code. At a point I used John Sundell’s CollectionConcurrencyKit to compare the performance of different approaches. After I had my numbers, I peaked into his code to double check what exactly am I measuring. …

Posted on

Swift Light IDE update, Jan 31st

For the ones who missed it last November, I’ve been playing with a Swift IDE prototype which allows you to easily develop Swift scripts for the mac. I shared a video showcase demoing how the tight integration of the IDE with the toolchain allows you to write scripts, capture inputs and outputs, and all that in a neat SwiftUI interface: More than anything else I worked on this to explore and demonstrate how easily I can build powerful Swift tools. …

Posted on

Yielding accessors in Swift

Edit: The post previsouly said yielding accessors were available only in nightly toolchains, but _read and _modify are also available in release Swift builds; they’re just _ prefixed to signify they are work-in-progress. It seems that Swift 5.6 is shaping up to a great iteration of the language and will bring a round improvements to performance-critical Swift code. I was reading through a pitch by Joe Groff on some improvements to ARC and ownership the other day when I noticed that he mentions that accessor coroutines are available in Swift trunk. …

Posted on

Swift Async Sequence extensions (part 2)

In Swift Async Sequence extensions (part 1) I covered simple ways to create an async sequence using a custom factory method and binding a sequence to a UI control via a custom assign method. This covered the “beginning” and “end” of the data stream (so to say) but what about processing or converting the data along the way? If you draw a parallel to Combine code — how would you build custom “operators” for your async sequence? …

Posted on

Swift Async Sequence extensions (part 1)

I’ve been trying out various ways to extend and build upon the currently available Concurrency APIs introduced in Swift 5.5 I believe the Concurrency APIs are intentionally somewhat minimal so that developers would intentionally fall back on Combine for complex tasks. Maybe I’m right or wrong but I can see how a lot of people will want to extend the Concurrency APIs to suit better their current tasks. In this post I’ll code a couple of extensions that show how to easily build your own concurrent power-ups. …

Posted on

Extending Xcode with power-ups

In this post I describe the technical setup of a small language experiment I developed to aid myself working on custom Xcode instruments. The need for a more flexible coding inside Xcode Last month, I prototyped a Swift IDE and became very interested in enhancing the experience of building with Swift. (Since Apple doesn’t hire remotely, I wonder what other companies are working in that area?) A little later, I came back to updating my custom Xcode Instrument called Timelane to support debugging new code based on the new Swift modern concurrency APIs: …

Posted on

Announcing: “Modern Concurrency in Swift”

I’m incredibly happy to share that today the new raywenderlich.com book “Modern Concurrency in Swift”, that I’ve been working on, is available at swiftconcurrencybook.com! Together with editors Sandra Grauschopf, Felipe Laso-Marsetti, Richard Turton, and Shai Mishali, we’ve been working very hard to get a book out as soon as possible on the newly released in 2021 Swift Concurrency: The book is written in the classic raywenderlich.com style that mixes key pieces of theory with step-by-step instructions, guiding the readers through working on practical, real-life projects. …

Posted on