Hey, is it supported (or does it make sense) to ha...
# multiplatform
k
Hey, is it supported (or does it make sense) to have
@Throws
annotation at methods in an interface, to be implemented in iOS side? Having interface like this:
Copy code
interface ExampleInterface {
  @Throws(Exception::class)
  fun doIt(): Boolean
}
And using implementing it on Swift side as:
Copy code
func doIt() throws -> Bool {
  // ...
}
gives an error :
Copy code
Throwing method cannot be an implementation of an @objc requirement because it returns a value of type 'Bool'; return 'Void' or a type that bridges to an Objective-C class
f
It seems it's not working, just found a (dirty) workaround.
Copy code
interface ExampleInterface {
    @Throws(Exception::class)
    suspend fun doIt(): Boolean
}
Copy code
class DummyTest: ExampleInterface {
    func doIt() async throws -> KotlinBoolean {
        return true
    }
    
}
But I'm not brave enough to find the real reason of the issue of interrop between Swift<->Obj-C 😭
k
This gives me an error that the class does not conform to the protocol (it treats
doIt
as overload), so that not working for me. Which Kotlin version you use?
f
I'm using the version Kotin > 2.0.0
m
Checkout the function declaration in the Objective-C header, that may give clues on how to implement it in Swift.
f
We can only follow what Swift give us from the obj-c declaration, and it's seem incompatible with it.
k
Seems like this is a LLVM issue, where generated header gives mutually exclusive errors https://github.com/llvm/llvm-project/issues/60024
f
if it's really the case, this issue is from last January and no update...
k
I guess no @Throws annotated methods for now. I put together an issue in YT, just to make sure my suspicion is correct