From c0b7e8cd4112eb401e31c9743d28b052c93439a4 Mon Sep 17 00:00:00 2001 From: Leonel Galan <727774+leonelgalan@users.noreply.github.com> Date: Wed, 25 Feb 2026 18:20:28 -0600 Subject: [PATCH] Fix Swift 6 actor isolation errors in RowndPlugin.swift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Xcode 26 (Swift 6.2) enforces @MainActor isolation even in Swift 5 language mode. The configure method accesses @MainActor-isolated APIs (subscribe() and $current) from a nonisolated context, causing build failures. This wraps the state subscription in Task { @MainActor }, which is the canonical Swift concurrency migration pattern. Build errors without fix: - RowndPlugin.swift:46:68 — call to main actor-isolated instance method 'subscribe' in a synchronous nonisolated context - RowndPlugin.swift:48:58 — main actor-isolated property '$current' can not be referenced from a nonisolated context --- ios/RowndPlugin.swift | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ios/RowndPlugin.swift b/ios/RowndPlugin.swift index 2793901..b0e2675 100644 --- a/ios/RowndPlugin.swift +++ b/ios/RowndPlugin.swift @@ -43,14 +43,17 @@ class RowndPlugin: NSObject { // Note: Subsequent calls to configure() will not reinitialize the state subscription // if it has already been initialized. This is intentional to prevent duplicate subscriptions. if self.state == nil { - let initializedState = Rownd.getInstance().state().subscribe { $0 } - self.state = initializedState - self.stateCancellable = initializedState.$current.sink { newState in - do { - RowndPluginEventEmitter.emitter.sendEvent( - withName: "update_state", body: try newState.toDictionary()) - } catch { - print("Failed to encode Rownd state: \(String(describing: error))") + Task { @MainActor [weak self] in + guard let self = self, self.state == nil else { return } + let initializedState = Rownd.getInstance().state().subscribe { $0 } + self.state = initializedState + self.stateCancellable = initializedState.$current.sink { newState in + do { + RowndPluginEventEmitter.emitter.sendEvent( + withName: "update_state", body: try newState.toDictionary()) + } catch { + print("Failed to encode Rownd state: \(String(describing: error))") + } } } }