未解决的参考iosmain kotlin多平台
我有其他KMM项目正在使用的Kotlin多平台库。我正在尝试构建这些KMM项目之一的iOS应用程序,但首先我需要将图书馆二进制文件发布给Maven Repo。
在尝试构建iOS ARM 64二进制文件时,它会在我使用的其中一个库中使用未解决的参考
失败。它只在Gradle任务CompileIosMainKotlinMetadata
上失败,构建项目非常有效,但是由于此错误,我无法生成二进制文件。
这是我常见的多平台lib设置gradle :( kotlin-multiplatform-lib-setup
)
plugins {
kotlin("multiplatform")
id("com.android.library")
}
kotlin {
android {
publishAllLibraryVariants()
}
ios()
sourceSets {
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}
android {
compileSdkVersion(31)
defaultConfig {
minSdkVersion(23)
targetSdkVersion(31)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets {
named("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
res.srcDirs("src/androidMain/res")
}
}
}
这是我正在使用的模块的build.gradle.kts
plugins {
id("kotlin-multiplatform-lib-setup")
id("publish-setup")
}
publishing {
publications.withType<MavenPublication> {
groupId = "${Constants.artifactGroup}.architecture"
artifactId = "core"
version = Constants.artifactVersion
}
}
kotlin {
ios()
sourceSets {
commonMain {
dependencies {
implementation(Deps.Badoo.reaktive)
implementation(Deps.Badoo.coroutinesInterop)
implementation(Deps.KotlinX.Coroutines.core)
implementation(Deps.uuid)
}
}
commonTest {
dependencies {
implementation(Deps.Badoo.reaktive)
implementation(Deps.KotlinX.Coroutines.core)
implementation(Deps.Badoo.reaktiveTesting)
}
}
iosMain {
dependencies {
implementation(Deps.Badoo.reaktive)
}
}
}
}
, 没有结果
kotlin {
ios {
binaries {
framework {
export(Deps.Badoo.reaktive)
transitiveExport = true
}
}
}
}
I have a Kotlin Multiplatform library that other KMM projects are using. I'm trying to build the iOS app of one of these KMM projects but first I need to publish the library binaries to a Maven repo.
When trying to build the iOS ARM 64 binaries it fails with Unresolved reference
for one of the libraries I'm using. It only fails on gradle task compileIosMainKotlinMetadata
, building the project works perfectly, but I cannot generate binaries because of this error.
This is my common multiplatform lib setup gradle: (kotlin-multiplatform-lib-setup
)
plugins {
kotlin("multiplatform")
id("com.android.library")
}
kotlin {
android {
publishAllLibraryVariants()
}
ios()
sourceSets {
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}
android {
compileSdkVersion(31)
defaultConfig {
minSdkVersion(23)
targetSdkVersion(31)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets {
named("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
res.srcDirs("src/androidMain/res")
}
}
}
And this is my build.gradle.kts for the module I'm working on:
plugins {
id("kotlin-multiplatform-lib-setup")
id("publish-setup")
}
publishing {
publications.withType<MavenPublication> {
groupId = "${Constants.artifactGroup}.architecture"
artifactId = "core"
version = Constants.artifactVersion
}
}
kotlin {
ios()
sourceSets {
commonMain {
dependencies {
implementation(Deps.Badoo.reaktive)
implementation(Deps.Badoo.coroutinesInterop)
implementation(Deps.KotlinX.Coroutines.core)
implementation(Deps.uuid)
}
}
commonTest {
dependencies {
implementation(Deps.Badoo.reaktive)
implementation(Deps.KotlinX.Coroutines.core)
implementation(Deps.Badoo.reaktiveTesting)
}
}
iosMain {
dependencies {
implementation(Deps.Badoo.reaktive)
}
}
}
}
I've also tested to add with no result
kotlin {
ios {
binaries {
framework {
export(Deps.Badoo.reaktive)
transitiveExport = true
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iOSMAIN源默认情况下在模块的build.gradle中不可用。因此,与其将
ios()
添加到源中,不如添加三种iOS配置,而不是为仅提供iOSMAIN的依赖项,而是包含所有配置,
而是这样做,
这样就添加了一个新的公共依赖关系来源处理所有iOS配置。
The iosMain sourceset is not available by default in your module's build.gradle. So instead of adding
ios()
to sourcesets, add the three iOS configurationsAnd instead of providing dependency for just iosMain, include all the configurations
Do this instead,
This way, it adds a new common dependency sourceset for handling all the iOS configurations.