Im a swift noob. Anyone know how to implement this...
# random
c
Im a swift noob. Anyone know how to implement this interface (created in kmp) with swift?
Copy code
__attribute__((swift_name("BrowserLauncher")))
@protocol SharedBrowserLauncher
@required
- (void)launchUrl:(NSString *)url __attribute__((swift_name("launch(url:)")));
@end
This is how I did it in android+kotlin class AndroidBrowserLauncher() : BrowserLauncher { override fun launch(url: String) { //do thing } }
Apparently it's this
Copy code
class Blah : BrowserLauncher{
    func launch(url: String) {
      //do thing
    }
}
👍 1
p
Should be the same in Swift. What do you get when doing autocompletion in Xcode? You can use @objcname("MyExportedName") in case the default class export adds prefixes.
c
autocomplete didn't seem to help + since im a swift noob I probably wasn't doing myself any favors with maybe some syntax errors.
seems like i couldn't google the right set of things to make it work though. then i just started guessing. 😂
p
On my experience, Xcode autocomplete is slow but find the things.
When the class you export belongs to a module that is not shared, the umbrella module, then the compiler adds library name prefixes and makes the autocomplete even worse. But overall it is able to give you a clue. In regards to swift, it is really similar to kotlin, it has its own syntax sugar too.