https://kotlinlang.org logo
Title
a

Aregev2

04/03/2018, 2:59 PM
Trying to mess up with klibs, made my first "util" library that has few functions, compiled it to a klib library, but I have no idea how to acess its functions in code, can someone help?
j

J-Rojas

04/03/2018, 3:06 PM
You will need to import the klib bindings. You will need to know the package of the code modules defined inside of the klib for importing.
a

Aregev2

04/03/2018, 3:07 PM
oh ok, let me try
my lib has only one class which is InputUtlils
j

J-Rojas

04/03/2018, 3:14 PM
that class should be defined in a package somehow, similar to Java (within a directory structure, have a package declaration). Then you can import it under that package path.
a

Aregev2

04/03/2018, 3:15 PM
okay, I will recompile the lib thank you
still cannot understand how to do that
i made a directory structure, recompiled it and still can't access the class
j

J-Rojas

04/03/2018, 3:32 PM
Your class should be in a directory structure like so:
mypackage/utils/InputUtils.kt
then at the top of the InputUtils file you would declare the package
package mypackage.utils
and in the client code, you would import the class
import mypackage.utils.InputUtils
.
a

Aregev2

04/03/2018, 3:36 PM
oh sorry if I am irritating this question, again how can I get my lib binding and where do I place them in my project files?
j

J-Rojas

04/03/2018, 4:22 PM
I'm not familiar with the command line Konan tool. I use gradle. Gradle offers a means to link klibs with your app code. This might give you some insights of how it works with the Konan CLI https://github.com/JetBrains/kotlin-native/blob/master/GRADLE_PLUGIN.md