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
Pablichjenkov
05/24/2024, 1:31 PM
Doesn't Xcode suggest what
type
to pass?
It suggests
Int32
to me. You can try swift
Int
too.
t
TARUN SAINI
05/24/2024, 1:35 PM
@Pablichjenkov
Xcode is suggesting KotlinInt.
If I am changing it to Int32 then
Type 'Example' does not conform to protocol 'ExampleInterface'
👍 1
m
Michael Krussel
05/24/2024, 1:39 PM
The type shouldn't be nullable.
p
Pablichjenkov
05/24/2024, 3:12 PM
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
TARUN SAINI
05/27/2024, 12:14 PM
@Michael Krussel@Pablichjenkov
Thanks, It is working with non-null type, I need to make param non null in kotlin as well.