How can I safely use a non-sendable object in an async context?

Yeah, I’m a big fan of this technique, but there’s one gotcha with assumeIsolated(…). It works fine on the latest systems but traps if you back deploy. In my case that meant that my code worked on macOS 15 but failed on macOS 14 )-:

I filed a bug about this (r. 139354130) but I don’t expect to see a fix because the older systems are missing key infrastructure required to make this work.

I ended up using non-isolated delegate methods that start a task to get back to the actor. That’s less than ideal, but I needed macOS 14 support.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

4 Likes