【问题标题】:Import one KMM module into another and expose it's classes to iOS将一个 KMM 模块导入另一个模块并将其类公开给 iOS
【发布时间】:2023-01-10 10:07:09
【问题描述】:

我正在尝试将几个 KMM 模块捆绑在一起,并使它们可以在 iOS 中访问。 我有模块A它进口模块B像这样:

val commonMain by getting {
        dependencies {
            api(project(mapOf("path" to ":moduleB")))
        }
    }

在android中,如果我导入moduleA,我也可以直接访问moduleB中的类。 但是在 iOS 上,我只能看到 moduleA 中的类。有没有办法让 moduleB 类在 iOS 中也可见,而无需将所有内容都移到 moduleA 中?

【问题讨论】:

    标签: android kotlin-multiplatform kotlin-multiplatform-mobile


    【解决方案1】:

    您需要手动配置本机框架以导出您希望 iOS 访问的模块:

        framework {
            ....
            transitiveExport = true
            export(project(":moduleB"))
        }
    

    另见:https://akjaw.com/modularizing-a-kotlin-multiplatform-mobile-project/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-28
      • 2019-08-08
      • 2022-01-08
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      • 1970-01-01
      • 2018-04-28
      相关资源
      最近更新 更多