Hi guys, I wanted to ask what is the current stat...
# kotlin-native
v
Hi guys, I wanted to ask what is the current status for using
protobuf
with
Kotlin/Native
? If anybody, can provide some useful links for this, I would be thankful.
k
protobuf is written in C++, not C
v
So it is not possible?
k
you will have to write a shim in C, but it is technically possible
v
protobuf compiler
can generate
objective-c
code and
Kotlin/Native
can interop with
objective-c
. Could this also work?
k
sure, but you still need APIs from the protobuf library, right?
v
At the moment I just want to access some objects defined in protobuf from native
d
What do you mean by "using"? What exactly are you trying to achieve?
v
I have
.proto
files and based on them C++ is generated and then used in a C++ project. I want to somehow be able to generate some code that should somehow be used in
Kotlin/Native
.
d
Oh I see. There should be a plugin for that, iirc.
v
Are you refering to this: • https://github.com/rouzwawi/grpc-kotlin Is this also for
Kotlin/Native?
k
You can use this to generate Kotlin code from Protobufs https://github.com/streem/pbandk . When you follow the instructions take note of this issue https://github.com/streem/pbandk/issues/18 . If you want go use a gradle task to generate code rather than terminal take note of this example https://github.com/streem/pbandk/blob/master/examples/gradle-and-jvm but I had to change line 36 to get it working. When you run installDist on the Protoc-gen-kotlin source files the instructions tell you to download, it should generate a Protoc-gen-kotlin.bat file, change line 36 to point to that file, was the only way I got it working
https://github.com/Kotlin/kotlinx.serialization this also supports serializing and deserializing protobufs
v
🙏Thanks! I will try it out!