Fucking Approachable Swift Concurrency

A no-bullshit guide to Swift concurrency. Learn async/await, actors, Sendable, and MainActor with simple mental models. No jargon, just clear explanations.

Fucking Approachable Swift Concurrency
Fucking Approachable Swift Concurrency

A no-bullshit guide to Swift concurrency. Learn async/await, actors, Sendable, and MainActor with simple mental models. No jargon, just clear explanations.

Fucking Approachable Swift Concurrency

I got buried in #concurrency and had to stop. 😅

The goal was to avoid using the `nonisolated` keyword in the context where #MainActor is the default isolation, but so far, I haven't found a better solution. 🤔

Here is the first response from the completed request! 🎉

It's taking longer than I thought, but I want to implement strict concurrency responsibly. 🕒🧐

At some points, it works with a project that has default isolation set on #MainActor. This is a default setting for #Xcode26, so I have to follow this rule. 🚀

#BuildInPublic #Swift

So it begins... 🌟

Until now, the package had #MainActor default isolation. This was intentional to gain a clear understanding of where the #Sendable declaration is necessary.

Now, it's time to make this package truly thread-safe! 🚀

#BuildInPublic #SwiftPackage #concurrency

How do you bridge the gap between legacy Apple APIs and Swift 6's strict concurrency model?

𝑀𝑎𝑖𝑛𝐴𝑐𝑡𝑜𝑟.𝑎𝑠𝑠𝑢𝑚𝑒𝐼𝑠𝑜𝑙𝑎𝑡𝑒𝑑 provides a MainActor context within synchronous methods, solving compatibility issues with APIs like 𝑁𝑆𝑇𝑒𝑥𝑡𝐴𝑡𝑡𝑎𝑐ℎ𝑚𝑒𝑛𝑡𝑉𝑖𝑒𝑤𝑃𝑟𝑜𝑣𝑖𝑑𝑒𝑟 and 𝑈𝐼𝐻𝑜𝑠𝑡𝑖𝑛𝑔𝐶𝑜𝑛𝑡𝑟𝑜𝑙𝑙𝑒𝑟. This is essential knowledge for Swift 6 migration!

🔗: https://fatbobman.com/en/posts/mainactor-assumeisolated/ by @fatbobman

#Swift6 #SwiftConcurrency #iOSDevelopment #MainActor

Using MainActor.assumeIsolated to Solve Legacy API Compatibility Issues with Swift 6

Use MainActor.assumeIsolated in a synchronous context to create closure safely on the main thread and return Sendable types, achieving full compatibility without warnings or errors.

fatbobman.com

Previous problems with Swift Concurrency, in my opinion, stemmed from originally overlooking this crucial assumption. 💭

Now we can set that Default Actor Isolation will rely on #MainActor. This means our entire app will work on the main thread by default. ✨

2/5

Изоляция с помощью глобальных акторов в Swift Concurrency: варианты на примере @MainActor

Привет, Хабр! Меня зовут Алексей Григорьев, я техлид iOS-разработки продукта Membrana в МТС. Это тариф с приложением для управления приватностью в сети и окружением. Swift Concurrency принесла множество инструментов для управления многопоточностью. Среди них глобальные акторы, которые помогают обеспечивать безопасность данных и контролировать потоки выполнения. Один из самых распространенных и полезных глобальных акторов — это @MainActor, который гарантирует выполнение операций в главном потоке приложения. В этом посте я на его примере покажу все варианты, как можно реализовать изоляцию и что в итоге выведет код: на каком потоке будут выполнены update, internal update и set в property.

https://habr.com/ru/companies/ru_mts/articles/904378/

#mainactor #swift_concurrency #Глобальная_изоляция #разработка_мобильных_приложений #разработка_под_ios #swift #программирование

Изоляция с помощью глобальных акторов в Swift Concurrency: варианты на примере @MainActor

Привет, Хабр! Меня зовут Алексей Григорьев, я техлид iOS-разработки продукта Membrana в МТС. Это тариф с приложением для управления приватностью в сети и окружением. Swift Concurrency принесла...

Хабр
Interesting, I've wrapped some code in `Task { @MainActor in /* code */ }` because I wanted to hide the concurrency warning, and now my app is way faster. I've no idea how, but I'm happy that this is the effect 🤣 #swiftlang #concurrency #swift #mainactor #task #indiedev
#Cheese #cat #cuteness #mainactor #centerstage

My daughter’s cat😻