I created a package that generates code from the proto files using SwiftProtobufPlugin. Everything works good within the package, the generated code is visible and can be used. Unfortunately, it doesn't work when this package is used as dependency in another package.
The project I created does exactly the same (except generating protos instead of enum) as GitHub - laevandus/SwiftExampleToomasKit.
To replicate the issue I just created an empty project and added SwiftExampleToomasKit as dependency. As result, seeing "Cannot find 'MyGeneratedEnum' in scope" error after an attempt to build the project. What am I doing wrong?
You're not doing anything explicitly wrong - it's a limitation of the current swift protobuf plugin. Plugins needs to be invoked at the "top level" of whatever project you have - so any plugins that are defined in your swift package dependencies aren't automatically invoked.
Yes, definitely. I wouldn't even really attempt to use the plugin to generate that kind of code, preferring instead to invoke the generator directly and drop the resulting source into a directory as a different path. The protobuf plugin itself only seems effective (right now anyway) if you're generating the code at the root of the project.