Hi, I am trying to implement an interface in swift...
# multiplatform
t
Hi, I am trying to implement an interface in swift which is defined in KMM library Kotlin interface:
Copy code
interface ExampleInterface{
  fun abs(value : Int)
}
Swift usage:
Copy code
class Example: ExampleInterface{
 func abs(value : KotlinInt?){

  }
}
It is giving error:
'KotlinInt' is ambiguous for type lookup in this context
kotlin version: 1.7.20 swfit: swift 4 xcode: 15.3 How can I fix this. Thanks
p
Doesn't Xcode suggest what
type
to pass? It suggests
Int32
to me. You can try swift
Int
too.
t
@Pablichjenkov Xcode is suggesting KotlinInt. If I am changing it to Int32 then
Type 'Example' does not conform to protocol 'ExampleInterface'
👍 1
m
The type shouldn't be nullable.
p
Ahh, I missed the nullability. Can you try not nullable in the swift override func? But still KotlinInt should work, especially if Xcode suggested it. Do a cleanup in Xcode and re compile on Android Studio, maybe that helps with some bad cache 🤷‍♂️
t
@Michael Krussel @Pablichjenkov Thanks, It is working with non-null type, I need to make param non null in kotlin as well.
💯 1