Xcode 16 beta 5 MainActor errors in a Swift 6 project while working in beta 4

After updating to Xcode 16.0 beta 5 (16A5221g) on macOS Sonoma 14.6 I am getting lots of errors like:

Main actor-isolated property '[property name]' can not be mutated from a nonisolated context

in classes that are marked as @MainActor at the class level, e.g.:

@MainActor final class MyClass: AnotherClass { ... }

The project uses Swift 6 and there are no errors in Xcode 16 beta 4.

I tried restarting, clearing Derived Data, cleaning build folder...

Anyone else encountering this issue with beta 5?

Xcode 16.1 beta seems to be having the same issue.

To test, I started from the default "Game" project template with SpriteKit and changed to GameScene.swift file to something simple like this:

// GameScene.swift
import SpriteKit
import GameplayKit

class GameScene: SKScene {  // GameScene is @MainActor as a subclass of SKNode
    
    var label : SKLabelNode = SKLabelNode(text: "Initial text")
    override func didMove(to view: SKView) {
        addChild(label)
    }
}

@MainActor final class State: GKState {
    
    unowned private let scene: GameScene
    
    init(scene: GameScene) {
        self.scene = scene
    }
    
    override func didEnter(from previousState: GKState?) {
        scene.label.text = "Entered State"  // Main actor-isolated property 'label' can not be referenced from a nonisolated context
                                                                   // Main actor-isolated property 'text' can not be mutated from a nonisolated context
    }
}

It seems that the @MainActor tag on the class State is not working for methods that were overridden. This is most likely because GKState is not marked so its methods are nonisolated. But what is the solution in this case?

Xcode 16 beta 5 MainActor errors in a Swift 6 project while working in beta 4
 
 
Q