Closed todorus closed 3 years ago
Hi @todorus. Can you please provide an example of the compiler errors you're seeing when you try to build the project and a snippet of the Kotlin code at the place where the error is being reported?
Thanks for the quick reply @garyp!
I was preparing a sample for you using the addressbook.proto, to avoid NDA issues, and noticed that did work. I compared the two and noticed our proto file had no package defined.
I am sorry to bother you with something this silly. Perhaps it can be documented as a requirement in a future release?
I'm glad you figured it out! Declaring a package in your proto file is considered best-practice when defining protobuf messages and that is the route I would recommend.
However, you are technically allowed to have a proto file with no package declaration. If you have a proto file like that for some reason, you'll just need to provide a kotlin_package
option when running protoc
to tell pbandk a valid package name to use in the generated code. For example:
protoc \
--pbandk_out=kotlin_package=my.package.name:./src/commonMain/kotlin/com/redacted/project/proto \
--proto_path=./src/commonMain/proto \
./src/commonMain/proto/ble_commands.proto
There's also an example at https://github.com/streem/pbandk#generating-code.
Hi there,
We are starting on a project with KMM and Protobuf, and we are looking into PBandK, as it looks like a very promising project to use for Kotlin Native code generation.
We've managed to install protoc and the plugin just fine, and have generated the code. However in our KMM project, the generated
ble_commands.kt
file is full of unresolved references. We figure it is something to do with the runtime library not being imported correctly, but cannot find out what is causing it.I've attached our .kts build file to this issue, and we would be much obliged if someone could point out our mistake(s). If needed, I can also create a public repo with our full project setup.
protoc v3.17.3 pbandk-protoc-gen v0.10.0