Kieren Searle
08/15/2022, 8:16 PMKieren Searle
08/15/2022, 8:16 PM#ifndef __MYWRAPPER_H
#define __MYWRAPPER_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct MyClass MyClass;
MyClass* newMyClass();
void MyClass_int_set(MyClass* v, int i);
int MyClass_int_get(MyClass* v);
void deleteMyClass(MyClass* v);
#ifdef __cplusplus
}
#endif
#endif
Kieren Searle
08/15/2022, 8:17 PMpackage = testlib
headers = MyWrapper.h
headerFilter = MyWrapper.h
staticLibraries = libtest.a
libraryPaths = src/nativeInterop/cinterop/libtest/
compilerOpts = -Isrc/nativeInterop/cinterop/libtest
Kieren Searle
08/15/2022, 8:18 PMkotlin {
android()
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
}
it.apply {
compilations.getByName("main") {
val libtest by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/libtest.def"))
packageName("testlib")
}
}
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting
val androidTest by getting
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
Kieren Searle
08/15/2022, 8:19 PMLandry Norris
08/15/2022, 8:23 PMLandry Norris
08/15/2022, 8:25 PMKieren Searle
08/15/2022, 8:25 PMLandry Norris
08/15/2022, 8:27 PMval libtest by cinterops.creating
. It will automatically check src/nativeInterop/cinterop/libtest.defKieren Searle
08/15/2022, 8:29 PMit.apply {
compilations.getByName("main") {
val libtest by cinterops.creating
}
}
Landry Norris
08/15/2022, 8:30 PMKieren Searle
08/15/2022, 8:31 PM[WARNING] The project is using Kotlin Multiplatform with hierarchical structure and disabled 'cinterop commonization'
See: <https://kotlinlang.org/docs/mpp-share-on-platforms.html#use-native-libraries-in-the-hierarchical-structure>
'cinterop commonization' can be enabled in your 'gradle.properties'
kotlin.mpp.enableCInteropCommonization=true
To hide this message, add to your 'gradle.properties'
kotlin.mpp.enableCInteropCommonization.nowarn=true
The following source sets are affected:
[iosMain]
The following cinterops are affected:
[cinterop:compilation/compileKotlinIosArm64/libtest, cinterop:compilation/compileKotlinIosSimulatorArm64/libtest, cinterop:compilation/compileKotlinIosX64/libtest]
Kieren Searle
08/15/2022, 8:33 PMLandry Norris
08/15/2022, 8:34 PMKieren Searle
08/15/2022, 8:36 PMKieren Searle
08/15/2022, 8:37 PM> Configure project :shared
Kotlin Multiplatform Projects are an Alpha feature. See: <https://kotlinlang.org/docs/reference/evolution/components-stability.html>. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.
The following Kotlin source sets were configured but not added to any Kotlin compilation:
* androidAndroidTestRelease
* androidTestFixtures
* androidTestFixturesDebug
* androidTestFixturesRelease
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See <https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets>
> Task :commonizeNativeDistribution
> Task :commonize
> Task :runCommonizer
> Task :shared:cinteropLibtestIosArm64 UP-TO-DATE
> Task :shared:cinteropLibtestIosSimulatorArm64 UP-TO-DATE
> Task :shared:cinteropLibtestIosX64 UP-TO-DATE
> Task :shared:commonizeCInterop UP-TO-DATE
> Task :shared:copyCommonizeCInteropForIde UP-TO-DATE
> Task :shared:commonize
> Task :shared:transformIosMainCInteropDependenciesMetadataForIde UP-TO-DATE
> Task :shared:transformIosTestCInteropDependenciesMetadataForIde UP-TO-DATE
> Task :shared:runCommonizer
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
BUILD SUCCESSFUL in 1s
8 actionable tasks: 1 executed, 7 up-to-date
Landry Norris
08/15/2022, 8:37 PMKieren Searle
08/15/2022, 8:40 PMLandry Norris
08/15/2022, 8:41 PMKieren Searle
08/15/2022, 8:46 PMtestlib
or MyClass
inside commonMain and I can't see anything under External Libraries in the project windowLandry Norris
08/15/2022, 8:46 PMKieren Searle
08/15/2022, 8:46 PMLandry Norris
08/15/2022, 8:47 PMKieren Searle
08/15/2022, 8:49 PMLandry Norris
08/15/2022, 8:50 PMKieren Searle
08/15/2022, 8:51 PMLandry Norris
08/15/2022, 8:51 PMKieren Searle
08/15/2022, 8:52 PMKieren Searle
08/15/2022, 8:53 PMLandry Norris
08/15/2022, 8:53 PMLandry Norris
08/15/2022, 8:55 PMKieren Searle
08/15/2022, 8:55 PMKieren Searle
08/15/2022, 9:00 PMKieren Searle
08/15/2022, 9:00 PM