How to package C++ plugin without private source code (only binaries + headers) in 4.20?

It’s probably been more than 10 engine versions since I experimented with doing this, so I don’t know if it became better supported than it was back then. I do know that during 4.20 preview there were issues building plugins just in the regular way, with errors relating to the new .precompiled files. From taking a quick look at the UBT code I think you’re on the right track with setting the bUsePrecompiled option. With that flag set, it looks like UBT skips compiling entirely and just copies in references to the object files from somewhere, which is presumably what you need. I don’t get the impression it’s intended for launcher engine modules only; if anything, it seems they may have generalized what they had before so that it can be applied in other cases, such as plugins.

Debug configs not working is to be expected I think, as the default plugin packaging process only compiles the plugin under Development and Shipping configs. If you need to distribute debug builds too, I think you’ll just need to run your own script instead (you could modify the existing BuildPlugincommand). Though of course that would depend on the new precompiled stuff not being hard coded with the assumption that it will never be used in a Debug config.

As for the clean issue, no idea. I’ve run into similar problems many times, and in the end I just try to avoid doing anything remotely non-standard with UE4 because you can guarantee these kind of headaches when you do. A far nicer approach than doing all of this would be to wrap up the protected code in a third party library, and then just have your module link that in and provide an integration layer. Obviously though that may be totally infeasible depending on how UE4-specific the code in question is.