Reputation: 1450
I created XCFramework MyFramework and try to connect it to KMM following the instruction https://kotlinlang.org/docs/mobile/add-dependencies.html#add-a-framework-without-cocoapods
MyFramework.xcframowork was placed inside root of KotlinMultiplatform project
my .def file looks like:
language = Objective-C
modules = MyFramework
package = MyFramework
in build.gradle.kts file I write:
kotlin {
android()
iosX64 {
compilations.getByName("main") {
val MyFramework by cinterops.creating {
// Path to .def file
defFile("src/nativeInterop/cinterop/MyFramework.def")
compilerOpts("-framework", "MyFramework", "-F/")
}
//val anotherInterop by cinterops.creating { /* ... */ }
}
binaries {
framework {
baseName = "shared"
}
}
binaries.all {
// Tell the linker where the framework is located.
linkerOpts("-framework", "MyFramework", "-F/")
}
}
But when I compile KMM project for iOS it writes me error:
Task :shared:cinteropEventBusTypesIosX64 FAILED
Exception in thread "main" java.lang.Error: /var/folders/8h/_7cdkbh56b3fc72xbkjpk4nd218xjp/T/8209547019177661418.m:1:9: fatal error: module 'MyFramework' not found
I think I write wrong path in compilerOpts("-framework", "MyFramework", "-F/"), but could be another reason.
Upvotes: 3
Views: 1488
Reputation: 31
On compilerOpts("-framework", "MyFramework", "-F/") you must write your path before your framework (write all path).
For example if your MyFramework.framework dir is on path: /MyDisk/MyProyects/MyKotlinProject/MyFramework.framework Your compilerOpts (and your linkerOpts) must be: compilerOpts("-framework", "MyFramework", "-F/MyDisk/MyProyects/MyKotlinProject")
Upvotes: 3