# \#mainactor

**URL:** https://forums.swift.org/tag/mainactor/574.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Isolated conformance check is skipped for decode(\[User\].self) and sorted() under default MainActor isolation](https://forums.swift.org/t/isolated-conformance-check-is-skipped-for-decode-user-self-and-sorted-under-default-mainactor-isolation/90800)

<div class="topic-metadata">

**Author:** [@salari\_dev](https://forums.swift.org/u/salari_dev)\
**Replies:** 0\
**Last updated:** [November 16, 2026, 2:42pm UTC](https://forums.swift.org/t/isolated-conformance-check-is-skipped-for-decode-user-self-and-sorted-under-default-mainactor-isolation/90800 "2026-11-16T14:42:37Z")

</div>

With -default-isolation MainActor, the SE-0470 rule that an isolated conformance can only be used in its own isolation domain is enforced for decode(User.self, ...) and not enforced for decode(\[User\].self, ...). The same…

---

## [Internal global actor on public API not accepted in XCFrameworks](https://forums.swift.org/t/internal-global-actor-on-public-api-not-accepted-in-xcframeworks/85179)

<div class="topic-metadata">

**Author:** [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Replies:** 1\
**Last updated:** [November 16, 2026, 6:30am UTC](https://forums.swift.org/t/internal-global-actor-on-public-api-not-accepted-in-xcframeworks/85179 "2026-11-16T06:30:14Z")

</div>

Currently if I try to use following code in FrameworkA for example: @globalActor actor MyGlobalActor: GlobalActor { static var shared: some Actor = MyGlobalActor() } @MyGlobalActor public func myFunc() { } fr…

---

## [Swift Concurrency MainActor does not execute when Swift DLL is called from .NET on Windows](https://forums.swift.org/t/swift-concurrency-mainactor-does-not-execute-when-swift-dll-is-called-from-net-on-windows/88469)

<div class="topic-metadata">

**Author:** [@edwardd20](https://forums.swift.org/u/edwardd20)\
**Replies:** 33\
**Last updated:** [August 5, 2026, 4:43pm UTC](https://forums.swift.org/t/swift-concurrency-mainactor-does-not-execute-when-swift-dll-is-called-from-net-on-windows/88469 "2026-08-05T16:43:36Z")

</div>

Sorry for this AI summary but I am a real person. I am building a Swift 6 dynamic library (DLL) for Windows that is consumed by a .NET 8 application through a C ABI/PInvoke interface. The goal is to share a Swift busin…

---

## [MainActor + KeyPathComparator + class = error](https://forums.swift.org/t/mainactor-keypathcomparator-class-error/85447)

<div class="topic-metadata">

**Author:** [@marco.masser](https://forums.swift.org/u/marco.masser)\
**Replies:** 10\
**Last updated:** [March 24, 2026, 4:30pm UTC](https://forums.swift.org/t/mainactor-keypathcomparator-class-error/85447 "2026-03-24T16:30:14Z")

</div>

I’m running into a situation where the compiler shows an error and I’m not quite sure if it is my code or the compiler that is incorrect. Any input would be greatly appreciated! My project uses Swift 6, MainActor defaul…

---

## [How are you handling @MainActor Delegates and Protocols in Swift 6?](https://forums.swift.org/t/how-are-you-handling-mainactor-delegates-and-protocols-in-swift-6/84597)

<div class="topic-metadata">

**Author:** [@Ananya294](https://forums.swift.org/u/Ananya294)\
**Replies:** 1\
**Last updated:** [February 7, 2026, 3:22pm UTC](https://forums.swift.org/t/how-are-you-handling-mainactor-delegates-and-protocols-in-swift-6/84597 "2026-02-07T15:22:40Z")

</div>

This specific warning usually happens because your class is "isolated" to the Main Actor (the UI thread), but the protocol doesn't guarantee that. When you try to assign the delegate, Swift worries that a background thre…

---

## [@MainActor conflict with async UseCase in SwiftUI ViewModel](https://forums.swift.org/t/mainactor-conflict-with-async-usecase-in-swiftui-viewmodel/79461)

<div class="topic-metadata">

**Author:** [@imany](https://forums.swift.org/u/imany)\
**Replies:** 10\
**Last updated:** [January 28, 2026, 8:10am UTC](https://forums.swift.org/t/mainactor-conflict-with-async-usecase-in-swiftui-viewmodel/79461 "2026-01-28T08:10:46Z")

</div>

I’m getting a data-race warning in my ProductViewModel : "Sending main actor-isolated 'self.getProductsUseCase' to nonisolated callee risks causing data races" @MainActor class ProductViewModel: ObservableObject { …

---

## [UITableViewDiffableDataSource cannot use struct when Default Actor isolation=Main Actor](https://forums.swift.org/t/uitableviewdiffabledatasource-cannot-use-struct-when-default-actor-isolation-main-actor/84359)

<div class="topic-metadata">

**Author:** [@xdkhan](https://forums.swift.org/u/xdkhan)\
**Replies:** 2\
**Last updated:** [January 26, 2026, 10:21am UTC](https://forums.swift.org/t/uitableviewdiffabledatasource-cannot-use-struct-when-default-actor-isolation-main-actor/84359 "2026-01-26T10:21:59Z")

</div>

import UIKit struct Song: Hashable, Sendable { let id: UUID let name: String } enum Section: String, Hashable, Sendable { case main } class ListViewController: UIViewController { var dataSource: UITabl…

---

## [Is @concurrent now the standard tool for shifting expensive synchronous work off the main actor?](https://forums.swift.org/t/is-concurrent-now-the-standard-tool-for-shifting-expensive-synchronous-work-off-the-main-actor/82976)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 44\
**Last updated:** [January 8, 2026, 9:13am UTC](https://forums.swift.org/t/is-concurrent-now-the-standard-tool-for-shifting-expensive-synchronous-work-off-the-main-actor/82976 "2026-01-08T09:13:06Z")

</div>

I reached for the new @concurrent attribute for the first time just now, and I want to verify that my understanding is correct and that I'm not missing a different recommended way to handle my situation. I'm writing a m…

---

## [@MainActor needs precondition to run on main actor?](https://forums.swift.org/t/mainactor-needs-precondition-to-run-on-main-actor/83588)

<div class="topic-metadata">

**Author:** [@realmtai](https://forums.swift.org/u/realmtai)\
**Replies:** 3\
**Last updated:** [December 6, 2025, 3:22pm UTC](https://forums.swift.org/t/mainactor-needs-precondition-to-run-on-main-actor/83588 "2025-12-06T15:22:56Z")

</div>

Hello folks, Does @MainActor need some sort of precondition to run on the main actor? I have an app intent with a perform method. The codebase is fully Swift6 with strict concurrency. It compiles and runs great. Howeve…

---

## [Default Main Actor isolation and protocol inheritance](https://forums.swift.org/t/default-main-actor-isolation-and-protocol-inheritance/80419)

<div class="topic-metadata">

**Author:** [@stephencelis](https://forums.swift.org/u/stephencelis)\
**Replies:** 9\
**Last updated:** [October 14, 2025, 9:41am UTC](https://forums.swift.org/t/default-main-actor-isolation-and-protocol-inheritance/80419 "2025-10-14T09:41:03Z")

</div>

I’ve been trying to understand how library code may work with new application targets that use main actor isolation and Swift 6 language mode and came across the following behavior. Given library code with a basic proto…

---

## [Insight needed for \`Equatable\` with Default MainActor Isolation](https://forums.swift.org/t/insight-needed-for-equatable-with-default-mainactor-isolation/81675)

<div class="topic-metadata">

**Author:** [@InstantInteractive](https://forums.swift.org/u/InstantInteractive)\
**Replies:** 9\
**Last updated:** [September 24, 2025, 7:54pm UTC](https://forums.swift.org/t/insight-needed-for-equatable-with-default-mainactor-isolation/81675 "2025-09-24T19:54:50Z")

</div>

I thought the following would have been resolved with Pull Request #82383 I’m using default actor isolation of MainActor as well as approachable concurrency. But when I have a protocol conforming to Equatable, I still n…

---

## [Swift 6.2 Approachable Concurrency & Default Actor Isolation with Core Data Transformable type](https://forums.swift.org/t/swift-6-2-approachable-concurrency-default-actor-isolation-with-core-data-transformable-type/82323)

<div class="topic-metadata">

**Author:** [@flyabb](https://forums.swift.org/u/flyabb)\
**Replies:** 0\
**Last updated:** [September 23, 2025, 11:29pm UTC](https://forums.swift.org/t/swift-6-2-approachable-concurrency-default-actor-isolation-with-core-data-transformable-type/82323 "2025-09-23T23:29:48Z")

</div>

I am using Xcode 26.0.1 and Swift 6.2 on my project with the following settings on the target: Approachable Concurrency: Yes Default Actor Isolation: MainActor Strict Concurrency Checking: Complete Swift Language Ver…

---

## [Unexpected UIApplication behavior under Swift Concurrency](https://forums.swift.org/t/unexpected-uiapplication-behavior-under-swift-concurrency/82160)

<div class="topic-metadata">

**Author:** [@TimofeiKarpovR](https://forums.swift.org/u/TimofeiKarpovR)\
**Replies:** 10\
**Last updated:** [September 17, 2025, 6:26pm UTC](https://forums.swift.org/t/unexpected-uiapplication-behavior-under-swift-concurrency/82160 "2025-09-17T18:26:07Z")

</div>

Hello, Calling UIApplication from a non-main-actor context triggers Main Thread Checker at runtime. Code sample: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() …

---

## [withTaskCancellationHandler operation ignores MainActor isolation inside global function](https://forums.swift.org/t/withtaskcancellationhandler-operation-ignores-mainactor-isolation-inside-global-function/81255)

<div class="topic-metadata">

**Author:** [@Fab1n](https://forums.swift.org/u/Fab1n)\
**Replies:** 2\
**Last updated:** [August 24, 2025, 11:59am UTC](https://forums.swift.org/t/withtaskcancellationhandler-operation-ignores-mainactor-isolation-inside-global-function/81255 "2025-08-24T11:59:58Z")

</div>

I have created a global function, passing the isolation as parameter with #isolation as default. Inside this global function withTaskCancellationHandler is called, expecting it to run operation on the same actor, becaus…

---

## [Cycle reference since changing to Default Actor Isolation Main Actor in nested structs](https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745)

<div class="topic-metadata">

**Author:** [@Seyden](https://forums.swift.org/u/Seyden)\
**Replies:** 3\
**Last updated:** [June 27, 2025, 8:19pm UTC](https://forums.swift.org/t/cycle-reference-since-changing-to-default-actor-isolation-main-actor-in-nested-structs/80745 "2025-06-27T20:19:22Z")

</div>

Hey guys, since the new default actor isolation, i wanted to try to set my project to MainActor default actor. After changing the setting i was getting basically an error for every struct that has Codable in it. My co…

---

## [Default Isolation: MainActor vs. property wrappers](https://forums.swift.org/t/default-isolation-mainactor-vs-property-wrappers/80416)

<div class="topic-metadata">

**Author:** [@mikchmie](https://forums.swift.org/u/mikchmie)\
**Replies:** 1\
**Last updated:** [June 11, 2025, 8:48pm UTC](https://forums.swift.org/t/default-isolation-mainactor-vs-property-wrappers/80416 "2025-06-11T20:48:18Z")

</div>

I'm testing the new "Default (Actor) Isolation: MainActor" build setting introduced in Xcode 26 / Swift 6.2 and encountered an issue. I wanted to mark all my DTO types (which are modeled as Sendable structs) as nonisolat…

---

## [Async XCTContext.runActivity?](https://forums.swift.org/t/async-xctcontext-runactivity/77481)

<div class="topic-metadata">

**Author:** [@David\_Catmull](https://forums.swift.org/u/David_Catmull)\
**Replies:** 1\
**Last updated:** [January 27, 2025, 3:45pm UTC](https://forums.swift.org/t/async-xctcontext-runactivity/77481 "2025-01-27T15:45:20Z")

</div>

I'm trying to create an async version of XCTContext.runActivity(). The challenge is how to make sure the async callback completes before returning to runActivity when it's all @MainActor. At the moment my function looks…

---

## [@MainActor should make the function async](https://forums.swift.org/t/mainactor-should-make-the-function-async/56095)

<div class="topic-metadata">

**Author:** [@Erik\_Aigner](https://forums.swift.org/u/Erik_Aigner)\
**Replies:** 4\
**Last updated:** [December 13, 2024, 7:35pm UTC](https://forums.swift.org/t/mainactor-should-make-the-function-async/56095 "2024-12-13T19:35:09Z")

</div>

The @MainActor attribute should be a guarantee that a method is called on the main thred, yet it is not. If you don't mark a @MainActor func explicitly as async, it is still possible to call it from some other queue/act…

---

## [GlobalActor and DispatchQueue pairing like @MainActor and DispatchQueue.main](https://forums.swift.org/t/globalactor-and-dispatchqueue-pairing-like-mainactor-and-dispatchqueue-main/76529)

<div class="topic-metadata">

**Author:** [@jubishop](https://forums.swift.org/u/jubishop)\
**Replies:** 17\
**Last updated:** [December 12, 2024, 7:11am UTC](https://forums.swift.org/t/globalactor-and-dispatchqueue-pairing-like-mainactor-and-dispatchqueue-main/76529 "2024-12-12T07:11:56Z")

</div>

Right now I can use @MainActor and DispatchQueue.main to effectively step into the @MainActor context, for example: @MainActor final class Example { var test = "hello" } var myExample = Example() now if I want to ch…

---

## [Is this runtime crash related to incorrect executor assumption / inheritence?](https://forums.swift.org/t/is-this-runtime-crash-related-to-incorrect-executor-assumption-inheritence/75568)

<div class="topic-metadata">

**Author:** [@Jon\_Reed](https://forums.swift.org/u/Jon_Reed)\
**Replies:** 0\
**Last updated:** [October 23, 2024, 4:09pm UTC](https://forums.swift.org/t/is-this-runtime-crash-related-to-incorrect-executor-assumption-inheritence/75568 "2024-10-23T16:09:54Z")

</div>

Recently I've run into a frustrating runtime crash that I believe may be related to a bug in the current Swift language version, but before I file a report I wanted to see if folks here could help check my understanding. …

---

## [@preconcurrency attribute on conformance to 'AProtocol' has no effect](https://forums.swift.org/t/preconcurrency-attribute-on-conformance-to-aprotocol-has-no-effect/75313)

<div class="topic-metadata">

**Author:** [@MasterWatcher](https://forums.swift.org/u/MasterWatcher)\
**Replies:** 1\
**Last updated:** [October 12, 2024, 3:22am UTC](https://forums.swift.org/t/preconcurrency-attribute-on-conformance-to-aprotocol-has-no-effect/75313 "2024-10-12T03:22:52Z")

</div>

When adopting Swift 6, it's common to have cases when @MainActor class needs to conform to a protocol that has no explicit isolation: protocol A { func foo() } class VC: UIViewController, A { func foo() {} // M…

---

## [What is the correct way to call UIApplication.shared.beginBackgroundTask no on the main thread?](https://forums.swift.org/t/what-is-the-correct-way-to-call-uiapplication-shared-beginbackgroundtask-no-on-the-main-thread/75196)

<div class="topic-metadata">

**Author:** [@nomnom](https://forums.swift.org/u/nomnom)\
**Replies:** 5\
**Last updated:** [October 11, 2024, 3:52pm UTC](https://forums.swift.org/t/what-is-the-correct-way-to-call-uiapplication-shared-beginbackgroundtask-no-on-the-main-thread/75196 "2024-10-11T15:52:51Z")

</div>

This is my newbie implementation for beginBackgroundTask @MainActor class BackgroundTaskManager { var backgroundTaskID: UIBackgroundTaskIdentifier = .invalid func startBackgroundTask() { backgroundTas…

---

## [Should awakeFromNib() be manually marked as @MainActor?](https://forums.swift.org/t/should-awakefromnib-be-manually-marked-as-mainactor/55926)

<div class="topic-metadata">

**Author:** [@nh7a](https://forums.swift.org/u/nh7a)\
**Replies:** 5\
**Last updated:** [October 9, 2024, 2:27am UTC](https://forums.swift.org/t/should-awakefromnib-be-manually-marked-as-mainactor/55926 "2024-10-09T02:27:54Z")

</div>

Hi there, Enabling concurrency warning with Xcode 13.3RC, it's produced hundreds of error as expected but I learned a ton of them were only because override'ed methods weren't isolated. For example, Add '@MainActor' …

---

## [Using @MainActor to ensure execution on the main thread](https://forums.swift.org/t/using-mainactor-to-ensure-execution-on-the-main-thread/60764)

<div class="topic-metadata">

**Author:** [@simonseyer](https://forums.swift.org/u/simonseyer)\
**Replies:** 5\
**Last updated:** [September 12, 2024, 8:14pm UTC](https://forums.swift.org/t/using-mainactor-to-ensure-execution-on-the-main-thread/60764 "2024-09-12T20:14:33Z")

</div>

Hi, I'm right now trying to build up a mental model of the new concurrency mechanisms, namely async await, actors and the MainActor. In the example code below I've annotated a class with @MainActor that bridges some Com…

---

## [Why doesn’t this MainActor lock the UI](https://forums.swift.org/t/why-doesn-t-this-mainactor-lock-the-ui/73695)

<div class="topic-metadata">

**Author:** [@trochoid](https://forums.swift.org/u/trochoid)\
**Replies:** 8\
**Last updated:** [August 7, 2024, 11:28pm UTC](https://forums.swift.org/t/why-doesn-t-this-mainactor-lock-the-ui/73695 "2024-08-07T23:28:22Z")

</div>

I’m a real concurrency novice but used it to continuously call a function that takes about 1/4 second to run. Initially I used “Task.detached {“ thinking this is a hard loop, there’s no awaits, so it needs to be in the b…

---

## [Converting function value of type '@MainActor () -\> ()' to '() -\> Void' loses global actor 'MainActor'](https://forums.swift.org/t/converting-function-value-of-type-mainactor-to-void-loses-global-actor-mainactor/59155)

<div class="topic-metadata">

**Author:** [@somu](https://forums.swift.org/u/somu)\
**Replies:** 11\
**Last updated:** [August 4, 2024, 1:43pm UTC](https://forums.swift.org/t/converting-function-value-of-type-mainactor-to-void-loses-global-actor-mainactor/59155 "2024-08-04T13:43:39Z")

</div>

Note: This is not a SwiftUI question, I was more concerned about the error thrown. Overview: I am encountering the error Converting function value of type '@MainActor () -\> ()' to '() -\> Void' loses global actor 'Main…

---

## [Use a \`Protocol\` of @MainActor instead of concrete @MainActor class produces an error](https://forums.swift.org/t/use-a-protocol-of-mainactor-instead-of-concrete-mainactor-class-produces-an-error/72542)

<div class="topic-metadata">

**Author:** [@MasterWatcher](https://forums.swift.org/u/MasterWatcher)\
**Replies:** 6\
**Last updated:** [June 17, 2024, 5:21pm UTC](https://forums.swift.org/t/use-a-protocol-of-mainactor-instead-of-concrete-mainactor-class-produces-an-error/72542 "2024-06-17T17:21:46Z")

</div>

Hi everyone! Could anyone please clarify how the concurrency checking works in my case? I have an actor that calls the foo method of a @MainActor class: actor MyActor { let property: MainActorClass init(propert…

---

## [Overloading on the isolation of a closure parameter](https://forums.swift.org/t/overloading-on-the-isolation-of-a-closure-parameter/72476)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 5\
**Last updated:** [June 17, 2024, 1:25pm UTC](https://forums.swift.org/t/overloading-on-the-isolation-of-a-closure-parameter/72476 "2024-06-17T13:25:10Z")

</div>

Here's the code that I perhaps naively attempted to write: public func expectError( from closure: ()async throws-\>() ) async throws { do { try await closure() throw "ExpectedErrorButGotNone"…

---

## [Using @MainActor on an ObservableObject or a method](https://forums.swift.org/t/using-mainactor-on-an-observableobject-or-a-method/65629)

<div class="topic-metadata">

**Author:** [@yo1995](https://forums.swift.org/u/yo1995)\
**Replies:** 2\
**Last updated:** [June 11, 2024, 11:01pm UTC](https://forums.swift.org/t/using-mainactor-on-an-observableobject-or-a-method/65629 "2024-06-11T23:01:30Z")

</div>

In most WWDC videos where a data model/view model with ObservableObject is used, I see the model is marked with @MainActor attribute. I wonder if it is the Apple recommended way of dealing with an observable data model …

---

## [MainActor isolated protocol affects on child class but not superclass](https://forums.swift.org/t/mainactor-isolated-protocol-affects-on-child-class-but-not-superclass/71661)

<div class="topic-metadata">

**Author:** [@hamtiko](https://forums.swift.org/u/hamtiko)\
**Replies:** 3\
**Last updated:** [June 11, 2024, 5:25am UTC](https://forums.swift.org/t/mainactor-isolated-protocol-affects-on-child-class-but-not-superclass/71661 "2024-06-11T05:25:45Z")

</div>

Hey all, I have faced following strange behavior of the swift compiler (Xcode 15.3): class UseCase { func test() { Base().foo() Child().foo() Child().fooIsolated() // Error: Call to main act…

[Next page](https://forums.swift.org/tag/mainactor/574.md?match_all_tags=true&page=1&tags%5B%5D=mainactor)
