yshrsmz / BuildKonfig

BuildConfig for Kotlin Multiplatform Project
Apache License 2.0
780 stars 32 forks source link

can support kotlin Native ? #76

Closed CMingTseng closed 1 year ago

CMingTseng commented 1 year ago

Dear Sir

as this project - https://github.com/bennyhuo/hello-kni

can use kotlin native to JNI ( kotlin --> c --> JNI --->Android/JVM)

when call JNI System.loadLibrary is "knlib" , that define at sharedLib in build.gradle.kts

https://github.com/bennyhuo/hello-kni/blob/27f787c13c27a2fd2e922b632eee66676761fce6/nativeLib/build.gradle.kts#L17

if use BuildKonfig to define a String buildConfigField like "JNI_NAME_PREFIX" value is "knlib"

we will get buildConfigField at app

but it can not work

THX

yshrsmz commented 1 year ago

Hi BuildKonfig supports K/N.

If what you mean is "how to access BuildKonfig defined in 'shared' module, from 'app' module", then BuildKonfig has internal visibility modifier by default, so use exposeObjectWithName to make it public.

CMingTseng commented 1 year ago

Dear Sir

sorry for my pool kotlin skill

hava any simple demo ?

THX

yshrsmz commented 1 year ago

https://github.com/yshrsmz/BuildKonfig#try-out-the-sample

You can modify sample project to try out various combinations(see sample/build directory to check what is generated).

CMingTseng commented 1 year ago

https://github.com/yshrsmz/BuildKonfig#try-out-the-sample

You can modify sample project to try out various combinations(see sample/build directory to check what is generated).

Dear Sir

This is my kotlin Native demo

https://github.com/cybernhl/hello-kni/blob/db889dfafcc820c0788e73746932f44a62dadbd4/nativeLib/build.gradle.kts#L66

if i define C_NAME_PREFIX_KCONFIG

i want use it at

https://github.com/cybernhl/hello-kni/blob/db889dfafcc820c0788e73746932f44a62dadbd4/nativeLib/src/nativeMain/kotlin/main.kt#L7

How to do ?

THX

yshrsmz commented 1 year ago

if you look at build directory, you'll find buildkonfig directory and that directory includes generated objects for all targets.

You can just import and use it just like ordinary object