gavin.hu
03/24/2025, 5:08 PMimport org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
}
kotlin {
androidTarget {
compilations.all {
compileTaskProvider.configure {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
}
}
val xcf = XCFramework()
listOf(
iosX64(),
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
xcf.add(this)
}
it.apply {
compilations.getByName("main") {
cinterops {
val Sqlcipher by creating {
defFile(project.file("src/nativeinterop/cinterop/sqlcipher.def"))
compilerOpts(
"-Isrc/iosMain/kotlin/nativeinterop/cinterop/",
"-DSQLITE_HAS_CODEC",
)
}
}
}
}
}
sourceSets {
val commonMain by getting
val iosX64Main by getting
val iosMain by creating {
dependsOn(commonMain)
}
iosX64Main.dependsOn(iosMain)
}
}
android {
namespace = "com.za.kmp_app_02"
compileSdk = 35
defaultConfig {
minSdk = 29
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
When I execute ./gradlew :shared:assembleXCFramework
, it reports an error:`> Task sharedassembleSharedReleaseXCFramework FAILED`
Caching disabled for task ':shared:assembleSharedReleaseXCFramework' because:
Caching has been disabled for the task
Task ':shared:assembleSharedReleaseXCFramework' is not up-to-date because:
Task has failed previously.
Starting process 'command 'xcodebuild''. Working directory: /Users/huguangyao/Desktop/KMPStudy/kmp_app_02/shared Command: xcodebuild -create-xcframework -framework /Users/huguangyao/Desktop/KMPStudy/kmp_app_02/shared/build/bin/iosX64/releaseFramework/shared.framework -output /Users/huguangyao/Desktop/KMPStudy/kmp_app_02/shared/build/XCFrameworks/release/shared.xcframework
Successfully started process 'command 'xcodebuild''
error: binaries with multiple platforms are not supported '/Users/huguangyao/Desktop/KMPStudy/kmp_app_02/shared/build/bin/iosX64/releaseFramework/shared.framework/shared'
0 problems were found storing the configuration cache.
See the complete report at file:///Users/huguangyao/Desktop/KMPStudy/kmp_app_02/build/reports/configuration-cache/qfi95qhwauguf3fgtnzaore1/4ba66rgy2db6lqd4ls4oehzsp/configuration-cache-report.html
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':shared:assembleSharedReleaseXCFramework'.
> Process 'command 'xcodebuild'' finished with non-zero exit value 70
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':shared:assembleSharedDebugXCFramework'.
> Process 'command 'xcodebuild'' finished with non-zero exit value 70
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
==============================================================================
BUILD FAILED in 4s
6 actionable tasks: 2 executed, 4 up-to-date
Watched directory hierarchies: [/Users/huguangyao/Desktop/KMPStudy/kmp_app_02]
Configuration cache entry stored.
Chrimaeon
03/24/2025, 6:00 PMgavin.hu
03/25/2025, 12:20 AMgavin.hu
03/25/2025, 12:26 AMgavin.hu
03/25/2025, 2:53 AM