-
-
Notifications
You must be signed in to change notification settings - Fork 742
KClass for Objective-C classes is not supported yet #1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do we know the cause of this yet? |
@Baileypollard yes, from the log I understand that koin doesn't support it currently. |
I have run into the same problem. My workaround for now is to create a wrapper class in kotlin. fun iosModule(application: UIApplication) = module {
single { UIApplicationWrapper(application) }
}
data class UIApplicationWrapper(val uiApplication: UIApplication) Seems to work :) |
Any progress on that? It blocks us to use Koin to resolve iOS dependencies. |
Is this related to what I've encountered? I can't single<TokenSource> {
TokenSourceImpl()
} //this doesn't work
single {
TokenSourceImpl()
} //this works
//kotlin function to get
fun Koin.get(objCClass: ObjCClass, parameter: Any): Any {
val kClazz = getOriginalKotlinClass(objCClass)!!
return get(kClazz) { parametersOf(parameter) }
} //swift usage
lazy var tokenSource = koin.get(objCClass: TokenSourceImpl.self) as! TokenSourceImpl Error: |
Same issue in Kmm |
My issue was not related to this. I needed to use |
@JohNan yes I confirm also, data class NativeDependencyWrapper(val userDefaults: NSUserDefaults)
single { NativeDependencyWrapper(userDefaults) } and then I can use it AppleSettings(get<NativeDependencyWrapper>().userDefaults) but we can not take this as solution it is just a workaround, I think koin should support this :) |
i would really appreciate if someone explain if this is a kmm limitation or the koin library issue? just curious why we can't use ios specific dependencies directly |
@osrl What do you mean with ObjCProtocol? I‘m trying to koin.get an interface that I defined in KMP and implemented in iOS, but it fails currently. |
|
@osrl Ah, I see. And what would be the way to call it from Swift? I‘m trying to create a function or property wrapper but can‘t get it to work. The plain call to my Kotlin extension function I wrote works without problem, but I would want to make an abstraction that does the whole dance with |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still looking forward to seeing this issue fixed 🙂 |
Reified type in Swift is making problems I guess. I've seen another issue related to this: #1316 |
Let's see how it goes. Feel free to reopen if needed |
@arnaudgiuliani sure thanks a lot! Finger crossed for 3.3.0 🤞 🙂 |
@arnaudgiuliani this doesn't work in new version, could you re-open it or should I fill a new one ? |
Describe the bug
The bug appears when you want to
get
a Objective-C classKoin version
3.0.1-alpha-3
Edit:
3.1.0
remains the sameEdit:
3.1.2
remains the samea simple example to demonstrate
It compiles fine but getting run time exception on IOS, the log below
The text was updated successfully, but these errors were encountered: