John O'Reilly
12/22/2024, 10:22 AMkotlin-inject-anvil and just struggling a little with createComponent etc plumbing. I have per platform application components and can't do likes of following in those (expect function needs to be in commonMain). Are there any examples on how to setup something like this?
@MergeComponent.CreateComponent
expect fun KClass<DesktopApplicationComponent>.createComponent(): DesktopApplicationComponenteygraber
12/22/2024, 12:04 PMCreateComponent at all, since you can just call DesktopApplicationComponent::class.create.
CreateComponent is only needed if you're creating your component in a common source set, because the common source set can't see the create function which is created in the target source set.John O'Reilly
12/22/2024, 1:28 PMpublic fun KClass<DesktopApplicationComponent>.create(): DesktopApplicationComponent =
KotlinInjectDesktopApplicationComponent::class.create()
e: file:///Users/joreilly/dev/github/BikeShare/common/build/generated/ksp/jvm/jvmMain/kotlin/dev/johnoreilly/common/di/KotlinInjectDesktopApplicationComponent.kt:22:52 None of the following candidates is applicable:
fun KotlinInjectDesktopApplicationComponent.Companion.create(): KotlinInjectDesktopApplicationComponent
fun KClass<DesktopApplicationComponent>.create(): DesktopApplicationComponenteygraber
12/22/2024, 1:39 PMme.tatarka.inject.generateCompanionExtensions=true?John O'Reilly
12/22/2024, 1:40 PMcreate
ksp {
arg("me.tatarka.inject.generateCompanionExtensions", "true")
}John O'Reilly
12/22/2024, 1:42 PMkotlin-inject .....just running in to issues migrating to kotlin-inject-anvileygraber
12/22/2024, 1:58 PMHristijan
12/22/2024, 2:05 PMJohn O'Reilly
12/22/2024, 2:11 PMJohn O'Reilly
12/22/2024, 6:53 PMlet applicationCompoonent = IosApplicationComponent.companion.create()eygraber
12/22/2024, 6:57 PMme.tatarka.inject.generateCompanionExtensions then there is no create function on the companion anymore.
I don't know if the KClass is accessible from Swift, but if not you could make a top level function in Kotlin that calls create on the KClass and call that function from Swift.John O'Reilly
12/22/2024, 7:15 PM@MergeComponent.CreateComponent
expect fun create(): IosApplicationComponent
and was able to use then in Swift like following
let applicationCompoonent = IosApplicationComponentCreateComponentKt.create()eygraber
12/22/2024, 7:21 PM