Hello, I'm using KMP in a small POC to produce a v...
# multiplatform
r
Hello, I'm using KMP in a small POC to produce a very simple library that can be distributed to my client apps. However, I'm running into some very unexpected (to me) usage on the iOS side. This is an interface in the common sources. I had expected that my iOS colleagues would be able to simply:
TimeProvider.companion.default()
but they aren't able to access
.companion
and have instead been trying to instantiate
Instant
manually without using the factory methods. Have I made a mistake in my build configuration? What's going on?
c
I'd need to double check, but it doesn't get converted to "companion" it's something like
TimeProvider.shared.default()
from memory
No mention of interfaces getting converted, so might not work for those only classes/objects etc
🤔 1
m
I think I had trouble accessing the companion object of an interface instead of a class from Swift.
r
Ok, that's a bit disappointing if the
companion object
syntax is unsupported on
interface
😞
c
Dont think this fixes it, but if you are providing swift packages, worth adding this for better API to iOS devs: https://skie.touchlab.co/#features
☝️ 1
m
I think it was possible but not pretty. my design changed shortly after and I didn't investigate a lot.
c
I mean I think converting to an abstract class might work?
Not tried tbh
r
unfortunately, using inheritance will cripple the ability to compose the behavior 😓
m
I think I was able to access it but it was different than the normal path. You would probably need to study the generated .h file to figure it out.
🙏 1