Travis Reitter
01/12/2022, 6:21 AM.m
and .h
files that way so I can use them in some actual
implementations? Or do I have to somehow build a library of the .m
files and link against that? I'm trying to follow the Gradle examples here but my iOS build is failing to find my header. Not sure if I have to adjust my Xcode project to include the header file or what.
Any help is greatly appreciated!Zode
01/12/2022, 8:34 AMplugins {
kotlin("multiplatform")
}
kotlin {
listOf(
iosX64(),
iosArm64(),
).forEach {
it.binaries.framework {
baseName = "yourModuleName"
}
}
// ...
}
Then you can use it in Xcode, just follow this https://kotlinlang.org/docs/kmm-integrate-in-existing-app.html#connect-the-framework-to-your-ios-project.Artyom Degtyarev [JB]
01/12/2022, 9:58 AMcinterop
block) -> (Xcode project building an app).Travis Reitter
01/12/2022, 4:38 PMcommonMain
, androidMain
, and iosMain
. Almost all the code in the shared module is in commonMain
already. But I have a very simple library where I built the Java version directly into the Android app and the Objective-C version directly into the iOS app. I've converted the Java version to Kotlin and I'm using that for the actual
implementations for androidMain
and now I'm trying to build the Objective-C version into the iosMain
. I have full control over the source files so I'm trying to do whatever is simplestTravis Reitter
01/12/2022, 4:39 PMTravis Reitter
01/12/2022, 4:41 PMcinterop
, that's doable (especially since this should be time-limited, as I mention). Are you aware of any code examples of that that I can check out?Travis Reitter
01/12/2022, 4:46 PMTravis Reitter
01/12/2022, 4:47 PMkpgalligan
01/12/2022, 5:03 PMkpgalligan
01/12/2022, 5:05 PMkpgalligan
01/12/2022, 5:07 PMTravis Reitter
01/13/2022, 5:48 AMcklib
might be a good fit. If not, I'll try building my Obj-C code into the library and using it through cinterops
Travis Reitter
01/13/2022, 5:53 AMTravis Reitter
01/18/2022, 5:23 AMplugins {
id("co.touchlab.cklib")
}
When I try to just include it as:
apply plugin: 'co.touchlab.cklib'
I get:
Plugin with id 'co.touchlab.cklib' not found.
even though it seems to be in Maven Central which I sourceTravis Reitter
01/18/2022, 5:24 AMTravis Reitter
01/18/2022, 5:32 AMclasspath("co.touchlab:cklib-gradle-plugin:$cklib_version")
Travis Reitter
01/18/2022, 5:51 AMcklib {
//config.kotlinVersion = "$kotlin_version"
create("sqlighter") {
language = co.touchlab.cklib.gradle.CompileToBitcode.Language.OBJC
}
}
yields:
> No signature of method: build_89t0gtdiazmlot5b0npjl25b8.cklib() is applicable for argument types: (build_89t0gtdiazmlot5b0npjl25b8$_run_closure3) values: [build_89t0gtdiazmlot5b0npjl25b8$_run_closure3@10e17582]
Possible solutions: mkdir(java.lang.Object), split(groovy.lang.Closure), wait(), file(java.lang.Object), wait(long), copy(groovy.lang.Closure)
is it necessary to set config.kotlinVersion
?
Don't I need to specify the Obj-C files somehow? I see zipline
does but neither the cklib
example nor Kermit seem to. If I do, should I just add lines like the following?:
create("sqlighter") {
language = co.touchlab.cklib.gradle.CompileToBitcode.Language.OBJC
srcDirs = project.files(
file("path/to/srcdir1"),
file("path/to/srcdir2")
)
kpgalligan
01/18/2022, 1:59 PMis it necessary to setYes?config.kotlinVersion
Don’t I need to specify the Obj-C files somehow?There’s a folder convention you can use. If your cklib name is “objcsample”, create a folder called “objcsample”, and put headers in a folder called “headers” and source in a folder called “cpp”. It would probably make more sense to call it something other than “cpp”, but I just copy/pasted this from the Kotlin/Native source 🙂
kpgalligan
01/18/2022, 1:59 PMbut what’s the Groovy equivalent of this?No idea. We’ve only used it with the Kotlin dsl.