Propagate child package plugin outputs to the parent package

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.

swift-protobuf/PLUGIN.md at main · apple/swift-protobuf · GitHub has some detail, and I thought previously called out this kind of scenario as unsupported, but as I'm looking again, I'm not seeing it.

I think your options for generating code from proto declarations within a dependent module are pretty much to do that generation and check in the resulting code as a part of that package.

Except the generated code is generated in the DerivedData directory, isn't it? Makes it a pain to check in.

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.