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?