this may be more of a gradle question, but what’s ...
# kotlin-native
l
this may be more of a gradle question, but what’s the right way to define a framework module that rolls up a couple of library modules? source set dependency doesn’t seem right (and isn’t working)
k
It’s kind of a gradle question. The final framework target just needs to include dependencies in gradle. “project” form: https://github.com/kpgalligan/sqldelight/blob/kpgalligan/2018-12-06/iosdriverchanges-v2/drivers/ios-driver/build.gradle and full groupartifactversion form https://github.com/touchlab/DroidconKotlin/blob/master/sessionize/lib/build.gradle
However, the framework won’t automatically have all code included from dependencies. I think you might need to list everything you want in the output binary and header in a kotlin class file
In the framework package
l
yikes
k
What, the config or the file inclusion situation? I’m not sure if you can override that. My use cases have all been building a framework for a specific app
Haven’t had to figure it out
l
the file inclusion situation
and yeah, that’s my use case too. I figure each of my apps gets a framework
k
It’s also been changing a lot, so my info might be a little old.
In my situation there’s code in the framework target that calls stuff in dependencies, so they get included. I’ve noticed in other situations if you don’t do that, the file from the dependency isn’t included. In iOS terms, there’s no equivalent to -ObjC flag
Well, not exactly equivalent. There’s no “keep everything “
l
thanks, playing with this now
yep, sure enough. instantiating one class brings most everything in.
s
Btw, the upcoming Kotlin 1.3.20 release has basic support for including everything from the library to Kotlin/Native framework. More details will be available later.
🎉 2
l
Awesome! Is this the
-Xexport-library
@olonho mentioned in another thread? on 1.3.11 I’m getting a “flag is not supported by this version of the compiler” error for that flag.
Yep, sure looks like it. This is very exciting.
🎄
i
FYI: Such a support is now added in Gradle plugins. See the examples here: https://github.com/ilmat192/kotlin-native-gradle-samples/
l
this is the best thread
found two bugs, I think. 1.
transitiveExport = true
seems to export transitive dependencies, even if you don’t export any direct dependencies (discovered this accidentally) 2. if your framework project itself has no kotlin sources, linking is skipped, even if you’ve asked to export dependencies.
but otherwise it seems to be working 🙂
i
@loganj 1) Do you mean that
transitiveExport = true
causes exporting all API-dependencies? E.g. in this cause
Copy code
kotlin {
    sourceSets.macosMain {
        dependencies {
            api 'foo:bar:1.0'
        }
    }

    targets.macos.binaries {
        framework {
            transitiveExport = true
        }
    }
}
foo:bar:1.0
is exported even if it isn't declared to be exported in the
framework
block, isn't it?
l
more like
Copy code
kotlin {
    sourceSets.macosMain {
        dependencies {
            api(project(":foo"))  // has its own dependency on project(":bar")
        }
    }

    targets.macos.binaries {
        framework {
            transitiveExport = true
            // export(project(":foo"))
        }
    }
}
if you have the above,
:bar
is exported
i
I cannot reproduce this behaviour. Could you please share a link to your project?
l
No, but I can try to create another small project that reproduces it. Will take me a little time.
🙏 1