Recommendations for adding script phases to a build with SPM

Hello everyone. The project I am working on is shifting from using CocoaPods to SPM and there is one "wrinkle" I'd like some advice on. The project has several framework projects containing code as well as the main app project. All of these make use of code generators (RSwift, Sourcery) at some point and these need to be run before the main build starts.

The problem is that SPM builds do not support the concept of adding script phases so there appears to be no easy way to incorporate these shell tools into the builds. Particularly in the framework projects which are pure SPM packages and therefore do not have your typical project files and build phases.

My question is - how to deal with shell based build phases in an SPM world?

Currently we are adding these phases in the main app's build. However they are not run before the builds of the SPM dependencies so effectively we have to run the build twice to ensure the code is up to date.