adjorno
10/08/2024, 7:28 AM> Task :shared:linkDebugFrameworkIosArm64 FAILED
error: KLIB resolver: Could not find "/Users/developer/Developer/Sources/KMP/shared/src/iosMain/c_interop/module/KMPWrapper.xcframework/ios-arm64_x86_64-simulator" in [/Users/developer/Developer/Sources/KMP, /Users/developer/.konan/klib, /Users/developer/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.0/klib/common, /Users/developer/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.0/klib/platform/ios_arm64]
error: Compilation finished with errors
as I am trying to export KMPWrapper xcFramework as a part of the shared module:
targets
.filterIsInstance<KotlinNativeTarget>()
.filter { it.konanTarget.family == Family.IOS }
.forEach {
val archXCFrameworkPath = when {
it.targetName.equals("arm64", ignoreCase = true) -> "$projectDir/src/iosMain/c_interop/module/KMPWrapper.xcframework/ios-arm64"
else -> "$projectDir/src/iosMain/c_interop/module/KMPWrapper.xcframework/ios-arm64_x86_64-simulator"
}
it.binaries.framework {
baseName = "shared"
isStatic = true
@OptIn(ExperimentalKotlinGradlePluginApi::class)
transitiveExport = true
export(files(archXCFrameworkPath))
}
it.compilations.getByName("main") {
val KMPWrapper by cinterops.creating {
// Path to the .def file
definitionFile.set(project.file("src/iosMain/c_interop/KMPWrapper.def"))
compilerOpts(
"-framework",
"KMPWrapper",
"-F$archXCFrameworkPath",
"-fmodules",
)
}
}
it.binaries.all {
linkerOpts(
"-framework",
"KMPWrapper",
"-F$archXCFrameworkPath",
"-fmodules"
)
}
}
What am I doing wrong?Blaž Vantur
10/08/2024, 7:35 AMadjorno
10/08/2024, 12:05 PMSergey Chuvashev
10/15/2024, 8:42 AMadjorno
10/15/2024, 8:48 AMBlaž Vantur
10/15/2024, 8:49 AMval xcf = XCFramework()
.
.
.
xcf.add(this)
adjorno
10/15/2024, 8:52 AMBlaž Vantur
10/15/2024, 8:57 AM.a
artefact and include the file directly to the project. And how do you then link it with the project? I guess some gradle command?
When I was manually trying to do cinterop I couldn’t find a way to link binary with the project so I retreat back to using that gradle plugin(I am also sure the answer lies in the implementation code of the plugin itself, but didn’t found the time to dig deeper into that source code).adjorno
10/15/2024, 9:00 AMswift-klib-plugin
does what you need under the hood. I think you can check out its sources and check what commands the author performs.