Skip to content

Swift cannot see Swift protocol conformance of ObjC class #84636

@an0

Description

@an0

Description

I have this Swift protocol:

@objc public protocol ViewControllerAPI {
    func foo()
}

A ObjC class adopts the protocol:

@interface ViewController : UIViewController <ViewControllerAPI>

@end

In anther Swift file, when I try to call the protocol method foo, Xcode complains ViewController has no member foo.

class Presenter {
    func present() {
        ViewController().foo() // Value of type 'ViewController' has no member 'foo'
    }
}

Reproduction

@objc public protocol ViewControllerAPI {
    func foo()
}
@interface ViewController : UIViewController <ViewControllerAPI>

@end
class Presenter {
    func present() {
        ViewController().foo() // Value of type 'ViewController' has no member 'foo'
    }
}

Expected behavior

ViewController().foo() works

Environment

6.2

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions