Skip to content

Main actor-isolated static property 'liveValue' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode #310

Answered by mbrandonw
bitomule asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @bitomule, currently @Dependency can be used from basically anywhere, and that means liveValue (and testValue/previewValue) must be non-isolated. You cannot have a dependency that is @MainActor bound because nothing is stopping you from doing:

// Not @MainActor
class Model { 
  @Dependency(\.mainActorClient) var}

This would require initializing a @MainActor thing from a non-necessarily @MainActor context.

Theoretically the tools in the library could start holding onto their isolation as (any Actor)?, but it's a big unknown of what that would do to ergonomics, and I don't think Swift's isolation tools are even up for the challenge. You would have static information of the type of iso…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bitomule
Comment options

@bitomule
Comment options

@mbrandonw
Comment options

Answer selected by bitomule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants