Build dependent packages automatically

A part of my application is written in Rust which gets compiled into an XCFramework and wrapped into its own SwiftPM package together with some Swift bridge code generated by UniFFI. My project depends on this package as a local package dependency (i.e. dependencies: [.package(path: ...)]).

I'd prefer to be able to keep the Rust sources in the same repo as my main project. But I don't want to check in the compiled binaries because they're too big. What I'd like instead is to build the Rust package as part of the main build, e.g. using a build tool plugin.

My finding/understanding so far is that that you can use build plugins when building targets only, not generate dependencies. And that the Rust package cannot be included as a target, only a dependency (because it consists of both binaries and Swift code).

Is my understanding correct or is there some way that I should be able to make this work? I know that I can move the Rust project to another repo, publish the binaries somewhere and use it as a regular SwiftPM dependency. But that would be disturbing to development, so I'm looking for another way.

Any advice is highly appreciated.

I don't know what the correct solution would be here, but can you use a Makefile or something similar to do your builds, rather than relying directly on swift build? That way you can have the package point to the local binary which doesn't exist but have Rust built it before swift build is run. It still makes your development process a bit awkward since you can easily iterate on both Swift and Rust at the same time but it would at least connect the two.

I do that when developing locally, but when a consuming package/app is depending on my package (which is a library, sorry should have added that), SwiftPM is all there is: The dependency is not there and as such I expect that the package resolution will fail.