How to extend an Objective-C class with Swift in a framework? How to extend an Objective-C class with Swift in a framework? objective-c objective-c

How to extend an Objective-C class with Swift in a framework?


Have you tried making the extension and function public?

public extension Sample {    public func PrettyPrint () {            print("\(x)")    }}


In a similar case, Tie's answer really helped me but it didn't work for me, I had to add @objc for the method:

public extension SearchBarWidget {    @objc public func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {        self.endEditing(true)    }}

The SearchBarWidget class was @objc public signatured.