Hey everyone, I cannot seem to get koin annotation...
# koin
r
Hey everyone, I cannot seem to get koin annotations working with expect/actual classes. The sample app is here. The setup is very simple:
Copy code
@Single
expect class MyClass() (Common)

@Single
actual class MyClass actual constructor() (Android/ios)
I have tried multiple variations - expect actual module, try defining the dependency in the module but nothing seems to work. What is the correct way for this? Thanks!
📍 1
Why would something like this not work? 🤔
Copy code
@Module
class MyModule {
    @Single
    fun provideMyClass() = MyClass()
}

//expect - common
expect class MyClass()

//actual - android/ios
actual class MyClass actual constructor()
p
@Ruben Quadros can you post the error log this is not much of a help right now
r
Here you go
Copy code
[ksp] --> Missing Definition for property 'myClass : io.github.rubenquadros.scratchpadkmm.MyClass_Expect' in 'io.github.rubenquadros.scratchpadkmm.MainViewModel'. Fix your configuration: add definition annotation on the class.
Hey @Pedro Alberto, did you get a chance to look at this?
p
Did you find a solution to this issue? (Sorry for writing in an old thread)
p
So what I have and it's working is
Copy code
@Single
expect class MyClass()

@Single
actual class MyClass actual constructor()
In my case am doing it in all places no sure is the best but it also requires the provider to use @Single
1
@arnaud.giuliani is this the correct way ?
a
yes it should work