Cannot form key path to actor-isolated property 'state'
Generated on 5/22/2025
1 search

This post is brought to you by Tailscan,
the best devtool for Tailwind CSS.
The error "Cannot form key path to actor-isolated property 'state'" is related to Swift's concurrency model, particularly when dealing with actor isolation. In Swift, actors are used to protect mutable state and ensure that it is accessed in a thread-safe manner. When a property is actor-isolated, it means that it can only be accessed within the context of that actor.
From the session "Migrate your app to Swift 6" at WWDC 2024, there are several strategies discussed to handle such concurrency issues:
-
Main Actor Isolation: If a function or property is isolated to the main actor, you need to ensure that any access to it is done on the main actor. This can be achieved by marking functions as
async
and usingawait
to access actor-isolated properties. Alternatively, you can annotate the function to run on the main actor directly. See more in the session (16:50). -
Non-Isolated Methods: If you have a method on an actor-isolated type that does not need to be isolated, you can declare it as non-isolated. This is useful for callbacks that do not make promises about where they are called from. Learn more about this approach (17:12).
-
Using
assumeIsolated
: When you know for certain that a call will be on a particular actor, you can useassumeIsolated
to inform the compiler that the code is already running on the correct actor, avoiding the need to start a new task. Explore this method (23:23).
These strategies help manage actor isolation and ensure that your code adheres to Swift's concurrency model, preventing data races and ensuring thread safety.

What’s new in Swift
Join us for an update on Swift. We’ll briefly go through a history of Swift over the past decade, and show you how the community has grown through workgroups, expanded the package ecosystem, and increased platform support. We’ll introduce you to a new language mode that achieves data-race safety by default, and a language subset that lets you run Swift on highly constrained systems. We’ll also explore some language updates including noncopyable types, typed throws, and improved C++ interoperability.

Deploy machine learning and AI models on-device with Core ML
Learn new ways to optimize speed and memory performance when you convert and run machine learning and AI models through Core ML. We’ll cover new options for model representations, performance insights, execution, and model stitching which can be used together to create compelling and private on-device experiences.

Migrate your app to Swift 6
Experience Swift 6 migration in action as we update an existing sample app. Learn how to migrate incrementally, module by module, and how the compiler helps you identify code that’s at risk of data races. Discover different techniques for ensuring clear isolation boundaries and eliminating concurrent access to shared mutable state.

Bring your machine learning and AI models to Apple silicon
Learn how to optimize your machine learning and AI models to leverage the power of Apple silicon. Review model conversion workflows to prepare your models for on-device deployment. Understand model compression techniques that are compatible with Apple silicon, and at what stages in your model deployment workflow you can apply them. We’ll also explore the tradeoffs between storage size, latency, power usage and accuracy.

A Swift Tour: Explore Swift’s features and design
Learn the essential features and design philosophy of the Swift programming language. We’ll explore how to model data, handle errors, use protocols, write concurrent code, and more while building up a Swift package that has a library, an HTTP server, and a command line client. Whether you’re just beginning your Swift journey or have been with us from the start, this talk will help you get the most out of the language.