Skip to content

Swift 6: Main actor-isolated property 'listener' cannot be used to satisfy nonisolated protocol requirement with RIBs 0.9.2 #43

Description

@jeongjinho

When generating a new RIB using the RIBs template (version 0.9.2) under Swift 6, I encounter the following compiler error:

Main actor-isolated property 'listener' cannot be used to satisfy nonisolated protocol requirement

This happens because the generated code marks the listener property as @MainActor, but the corresponding protocol requirement is nonisolated.

Steps to Reproduce
1. Create a new RIB module using the RIBs template on version 0.9.2.
2. Build the project in Xcode with Swift 6 enabled.
3. Observe the compiler error above.

Expected Behavior

Generated RIB code should compile successfully under Swift 6 without actor isolation mismatches.

Actual Behavior

Compilation fails due to mismatch between @MainActor isolated property and nonisolated protocol requirement.

Environment
• RIBs version: 0.9.2
• Swift version: 6.0

Is there a recommended way to update the generated RIBs code (or RIBs framework itself) so that the listener property works correctly with Swift 6’s stricter actor isolation rules?
Should protocol definitions also be annotated with @MainActor, or is there an official workaround planned?

Activity

  1. alexvbush commented on Oct 4, 2025

    @alexvbush
    Collaborator

    I am currently investigating this and working on a proper solution.

    I'm still in research mode so my current conclusions might change later but the intent is to mark everything in the framework that supposed to be main thread related, such as the presenter protocol, as @MainActor to force the main thread isolation. Potentially this will also applies to the ViewableRouter/ViewableRouting as well. Everything else should be marked nonisolated as actions on those objects can happen on the main thread or a background thread (especially in the case of headless RIBs with no UI). But this is my current understanding and perhaps I'm missing something.

    This is related to #6 as fixing and setting the right swift concurrency isolation scopes will most likely help with future addition of async/await support.

    I have some progress on this already and will try to have a proof of concept working next week. But, currently I'm facing some swift compiler limitations that might force a breaking change, which I want to avoid, on the users of RIBs framework. Specifically with marking certain things like var listener: PresentableListener? { get set } in protocol MyRIBPresentable: Presentable declarations as nonisolated explicitly. This potentially would be a minor change though, comparing to more widespread marking of nonisolated or @MainActor across codebases. That is what I'm trying to avoid by carefully setting nonisolated/@MainActor on the parent types that the users of the framework subclass from or adopt.

  2. alexvbush commented on Oct 19, 2025

    @alexvbush
    Collaborator

    @jeongjinho here's a working prototype that solves this issue: #45
    Moving the conversation there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions