SwiftLee Weekly - Issue 261


This week's SwiftLee Weekly covers:

  • Structured Concurrency?
  • SwiftUI Animations
  • Threading in Swift Concurrency

Enjoy this week's SwiftLee Weekly!

THIS WEEK'S BLOG POST

What is Structured Concurrency?

I'm working hard on my Swift Concurrency Course, and AppDevCon talk on concurrency. While Swift Concurrency can be daunting, it's often because we don't fully understand the foundational concept. A part of this is understanding what Structured Concurrency really means and how it helps us write easier-to-maintain asynchronous code.

Swift Concurrency Course Waitlist - Closing soon!

I'm inviting students to my brand new course in batches with the first invites going out next week. The course will be available with an extra discount for those on the waitlist. Since I already have multiple hundreds of developers on the list, I'll be closing the list soon. So join here if you haven't yet.

SPONSORED

Webinar alert: Want to ship more code faster for iOS?

If your iOS builds take longer than 12 minutes, sign up for this tips-and-tricks rich session for building and releasing faster. Save your seat now.

CURATED FROM THE COMMUNITY

Safer Swift: How ~Copyable Prevents Hidden Bugs

I’ve read several articles on Copyable, but this one by Artur Gruchała resonated well. The code example is easy to follow and explains clearly when you want to use ~Copyable (new since Swift 5.9).
arturgruchala.com

Designing a custom lazy list in SwiftUI with better performance

The List element in SwiftUI is easy to use but can become slower when used at a larger scale. If performance becomes an issue, this article by Natalia Panferova can help.
nilcoalescing.com

Symmetrical and asymmetrical transitions in SwiftUI with the Scroll Transition modifier

Animate elements in a list using the scroll transition modifier in SwiftUI. The videos in this article make the code examples easier to follow. (Note: You might need to click on the video elements; there are no controls, but they exist!)
createwithswift.com

Animatable Protocol - Taming Unruly SwiftUI Animations

Speaking of animations: the Animatable protocol can help you out when a SwiftUI animation doesn’t work as expected. The article shows an example of such and a working code example that solves it accordingly.
fatbobman.com

An Ode to Swift Enums: The View Models That Could

MVVME: Model-View-ViewModel-Enum. Jokes aside, enums can be a great alternative to structures for lightweight view models, and Jordan Morgan explains how.
swiftjectivec.com

SWIFT EVOLUTION

An overview of last week's Swift Proposal state changes. Check them out when they're in review, as it's your opportunity to influence the direction of Swift's future.

GIVEAWAY WINNER

AppDevCon Giveaway Winner

I'm happy to announce Marco Witt as the winner of the free AppDevCon ticket. We'll get in touch with you soon and I look forward meeting you at the conference! For all others, get your tickets here and don't miss out on 8 tracks full of talks.

CODE SNIPPET OF THE WEEK

Threading in Swift Concurrency

You can find this post on Twitter/X, LinkedIn, or Bluesky.

More about this code snippet in the Question of the Week section.

twitter profile avatar
Antoine v.d. SwiftLee 
Twitter Logo
@twannl
5:54 PM • Feb 25, 2025
5
Retweets
109
Likes

QUESTION OF THE WEEK

Which of these points will run on the main thread?

This week, I decided to follow up on one of my social media posts on threading in Swift Concurrency. I've had quite a few replies and discussions on the correct answer, but most of all, I realized many of us still have a hard time understanding how async functions get dispatched to threads.

It resulted in a new thread on the Swift Forums to clarify things, but also a mention of SE-461 Run nonisolated async functions on the caller's actor by default. This proposal is one I want to highlight in this week's newsletter.

The Swift core team recognizes the issues we're running into and SE-461 is one of the improvements they're making. To quote the proposal:

Swift's general philosophy is to prioritize safety and ease-of-use over performance, while still providing tools to write more efficient code. The current behavior of nonisolated async functions prioritizes main actor responsiveness at the expense of usability.
This proposal changes the behavior of nonisolated async functions to run on the caller's actor by default, and introduces an explicit way to state that an async function always switches off of an actor to run.

It's important to realize that we're still in the early days of Swift Concurrency. Last week's release of Swift 6.1 introduced several improvements, and there are more to come. This is simply a result of real-world usage and collected feedback—we're all working together to create a more solid concurrency framework.

My contribution can be found in my free articles on Swift Concurrency, but soon, I'll have an even bigger role in helping you become an expert on anything related to concurrency. Hundreds of developers are already on the waitlist, and I'd love for you to join the concurrency course waitlist, too.

Want to have your question answered next week? Ask your question via this form (anonymously) or reply to this email with your question.

EARN ROCKETSIM LIFETIME

Share and Earn RocketSim Lifetime & a 1-on-1 coaching session

Apple has recognized RocketSim as an Essential Developer Tool in the Mac App Store, and now you can get lifetime Pro access by sharing your unique referral link!

How to get started:

[RH_REFLINK GOES HERE]

Rewards:

  • Earn your first reward after just 3 sign-ups!
  • Check your progress anytime using your referral dashboard.
  • The grand prize? A personalized 1-on-1 career coaching session!

Several subscribers have already claimed their rewards—will you be next?

Thank you so much for your support, and until next Tuesday,

Antoine

SwiftLee Weekly by Antoine van der Lee

A new SwiftLee article, code snippet, Swift Evolution updates, 5 top community articles, and a weekly answer to a question from the community to level up your Swift skills.

Read more from SwiftLee Weekly by Antoine van der Lee

This week's SwiftLee Weekly covers: Rendering Pixel Art in SwiftUI .animation() vs. withAnimation() An @Observable performance risk Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST Picker in SwiftUI explained with code examples While AI greatly helps us, I always look for a quick visual overview of different SwiftUI element styles. This is why I'm writing about pickers in SwiftUI this week: to give a visual overview of the different available styles that I can revisit myself....

This week's SwiftLee Weekly covers: Conference ticket giveaway Task.yield vs. Task.sleep What is a good course price? Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST Task.sleep() vs. Task.yield(): The differences explained I've used both methods in my code, but sleep has always been easier to understand than Task.yield(). It's time to dive into the differences and showcase a few examples. SPONSORED Codemagic makes Apple M2 machines available, even on the free tier! Codemagic is the...

This week's SwiftLee Weekly covers: Swift 6 ScrollTargetBehavior protocol A major milestone for RocketSim Enjoy this week's SwiftLee Weekly! THIS WEEK'S BLOG POST Swift 6: What’s New and How to Migrate The release of Swift 6 caused quite some discussion for those migrating their projects. I've seen several conference talks with slides showing hundreds of warnings and compiler errors after initially switching to Swift 6 language mode. It's time to help you get started with the migration after...