Skip to content

Hint generation (i.e. multi-module aggregation) and top-level function injection only works on jvm/android targets #460

@r0adkll

Description

@r0adkll

Description

I have a case where contributed bindings are not being found when compiling my iOS graph in a separate module. Take the example

// feature/commonMain/…/FeatureDependency.kt
interface FeatureDependency

@ContributesBinding(AppScope::class)
@Inject
class FeatureDependencyImpl : FeatureDependency 

// shared/iosMain/…/IosAppGraph.kt
@DependencyGraph(AppScope::class)
interface IosAppGraph : AppGraph {
  val featureDep: FeatureDependency
}

When running gw :shared:compileKotlinIosSimulatorArm64 it will fail with

e: file:///…/IosAppGraph.kt:13:3 [Metro/MissingBinding] Cannot find an @Inject constructor or @Provides-annotated function/property for: com.example.feature.FeatureDependency

    com.example.feature.FeatureDependency is requested at
        [com.example.metrobugreproduction.IosAppGraph] com.example.metrobugreproduction.IosAppGraph#featureDep

Self-contained Reproducer

See https://github.com/r0adkll/MetroBugs/tree/dh/ios-compilation

Steps to reproduce:

  1. Run ./gradlew :shared:compileKotlinIosSimulatorArm64
  2. See MissingBinding error

Metro version

0.3.2

Context

I ran into this in my migration where I have iOS specific app graph stuff for exposing/creating the compose UIViewController for the swift code and when migrating hit a bunch of these missing binding exceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked:waiting-for-upstreamThis issue or PR is dependent on upstream Kotlin compiler changes/fixes

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions