Global Actor conformed to public NSObject

I have an interesting issue, When I create a global actor

@objc @globalActor public final actor MyActor {
    static public let shared = MyActor()
    private init(){}

and Conform it to a class that inherits NSObject

public final class MyClass: NSObject {

@objc public var propertyOne: SomeType

@objc func functionOne() async {
///Some Logic


I then use xcode build to generate an XCFramework

When I import the Module the swift compiler is all kinds of unhappy in regards to this actor

inside of MyModule.swiftmodule/arm64-apple-ios.private.swiftinterface I keep getting the error.
No type named 'MyActor' in module 'MyModule' on a variety of properties and functions that are public and are available in Objective-C via @objc func or @objc var/let.

I have no Idea why this is occurring, however it seems to be centered around NSObject classes.

Any suggestions on the reason why this could be happening is greatly appreciated.



Seems like a bug one way or another (either this should work or the compiler should reject it). Would you mind filing a GitHub issue?

@tshortli Thanks, I filed an issue on swift's GitHub. Example Project included.

1 Like

I took a look and this is the same issue that was fixed by Frontend: Enable `$GlobalActors` by default by tshortli · Pull Request #61421 · apple/swift · GitHub. Unfortunately Swift 5.7 has a bug that prevents the definition of public global actor types in modules with library evolution enabled.

Thanks for you work. I regressed my global actor back into internal methods until Swift 5.8 is released. Much appreciated!

1 Like