Hi! I'm running into a warning from a SwiftUI.DynamicProperty
on a 6.0 development build (swift-6.0-DEVELOPMENT-SNAPSHOT-2024-03-26-a
).
I am attempting to build a type (conforming to DynamicProperty
) that should also be MainActor
. This type with also need a custom update
function. Here is a simple custom wrapper (handwaving over the orthogonal missing pieces) that shows the warning:
import SwiftUI
@MainActor struct MainProperty: DynamicProperty {
// Main actor-isolated instance method 'update()' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode
@MainActor func update() {
}
}
Is there anything I can do about that warning? Does the warning correctly imply that this will be a legit compiler error when 6.0 ships?
I can find (at least) two examples of types adopting DynamicProperty
from Apple that are also MainActor
: FetchRequest
and SectionedFetchRequest
. What is confusing is that both FetchRequest
^1 and SectionedFetchRequest
^2 explicitly declare their update
method to be MainActor
. Is there anything missing from my Wrapper
declaration that can get me what I'm looking for? Any more advice about that? Thanks!