I have a multi-module Kotlin Multiplatform library...
# multiplatform
b
I have a multi-module Kotlin Multiplatform library for Android+iOS+tvOS that looks something like the following:
Copy code
MyProject
├── Library
├── Library-common
├── Library-submodule
└── Library-submodule-with-cinterops # has a cinterop def for a native dependency, let's call it Foo
The idea is that Library depends on
Library-submodule
and
Library-submodule-with-cinterops
, both of which depend on
Library-common
. All is working fine, with the exception of the
Library-submodule-with-cinterops
. I can build that module in isolation, which generates the .aar, .framework files, and .klibs, but when I build
Library
, the linker fails with the following:
Copy code
The /Applications/Xcode <http://11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld|11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld> command returned non-zero exit code: 1.
output:
ld: framework not found Foo
I’m not sure why
-framework Foo
is being added to the
ld
command (executed as part of
:Library:linkReleaseFrameworkApple
), I’m guessing I need to tell the linker where to find it, but I’m not sure how to go about it. Does anyone have any pointers for how I might fix it?
I’ve spent a bit more time debugging this. The
Library-submodule-with-cinterops
is defined as a dependency of
commonMain
like so:
Copy code
api project(":Libary-submodule-with-cinterops")
If I add the following to the
framework
options in `Library/build.gradle`:
Copy code
export project(':Libary-submodule-with-cinterops')
I get the following output during
:Library:linkDebugFrameworkApple
(snipped for brevity):
Copy code
> Task :Library:linkDebugFrameworkApple FAILED
w: Following libraries are specified to be exported with -Xexport-library, but not included to the build:
/path/to/MyProject/Library-submodule-with-cinterops/build/libs/apple/main/Library-submodule-with-cinterops-cinterop-Foo.klib

Included libraries:
<-- snip -->
/path/to/MyProject/Library-submodule-with-cinterops/build/classes/kotlin/apple/main/Library-submodule-with-cinterops.klib
/path/to/MyProject/Library-submodule-with-cinterops/build/classes/kotlin/apple/main/Library-submodule-with-cinterops-cinterop-Foo.klib
<-- snip -->
e: /Applications/Xcode <http://11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld|11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld> invocation reported errors

The /Applications/Xcode <http://11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld|11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld> command returned non-zero exit code: 1.
output:
ld: framework not found Foo