Hi, I have a question - I have a project using the...
# kotlin-native
a
Hi, I have a question - I have a project using the kotlin-multiplatform plugin consisting of multiple modules. I am able to get everything compiling (and get a jar and klib for each module). I am trying to figure out how to get a single iOS framework built from the combination of all these klibs. I was trying to create a separate gradle module that depends on all the aforementioned modules and set:
Copy code
fromPreset(presets.iosX64, 'ios') {
            compilations.main.outputKinds('FRAMEWORK')
        }
in order to get one framework, but I notice that: 1. I have to have code within this module in order for it to build a framework 2. the framework doesn’t include the dependencies I’ve tried also adding the set of dependencies explicitly under
iosMain
(with
api
instead of
implementation
and the
implementation
counterparts in
commonMain
), and tried adding a block with:
Copy code
iosX64("ios").binaries {
        framework {
            export project(":one")
            export project(':two')
            export project(":three")

            transitiveExport = true
        }
    }
but the framework i am getting only has the files from this specific module without the dependencies. if i explicitly reference a class from one of these dependent modules, the header file that is generated grows, but i want a way to include them without manually referencing something from each module. may someone point me to the right direction on how to combine the klibs from these multiple modules into one single iOS framework?
Adding
export
directives should actually help. Can you share you
build.gradle
?
Have you tried adding dependencies to
api
configuration and to
export
directive at the same time?
a
thank you - let me check your project and try that again and if not i can put together a sample project
i put together a sample app that shows this - https://github.com/ahmedre/mppdemo
s
You project is misconfigured. https://github.com/ahmedre/mppdemo/blob/cf764f0a21e527e85456adeace8c0828a74ff00b/everything/build.gradle#L7
Copy code
compilations.main.outputKinds('FRAMEWORK')
This line defines the framework which doesn’t export its dependencies. https://github.com/ahmedre/mppdemo/blob/cf764f0a21e527e85456adeace8c0828a74ff00b/everything/build.gradle#L47
Copy code
iosX64("ios").binaries {
        framework {
            export project(":core")
            export project(":data")
            export project(":extra")

            transitiveExport = true
        }
    }
This block defines the framework which does export its dependencies. So your build script defines two frameworks, one of them doesn’t export dependencies. Remove
compilations.main.outputKinds('FRAMEWORK')
and try again.
👍 1
a
thank you - i can see the symbols from the dependencies in the header now!
👍 1