Any way to inject/override a dependency of a dependency on the Swift package level?

Here is a ridiculous example: let's say that I have my own Foundation implementation and I want to build a project using this new Foundation package. I have other external dependencies that also depend on Foundation.

So let's say that I have MyProject with AwesomeLibrary and NotFoundation as dependencies.

Is there a way for me to have AwesomeLibrary compiled in MyProject as usual, but with NotFoundation aliased as Foundation? To make it so that every import Foundation actually imports NotFoundation inside the library.

That would only work for source packages of course, not prebuilt binaries. I searched the documentation and Swift Evolutions and I did find ways to alias products of dependencies but not dependencies of dependencies.

The actual reason I'm willing to do that is that I found a problem in XCTest bundled with the Swift Linux toolchain. I already filled an issue on GitHub but in the meantime I would love to temporarily build the project with my own dirty patched XCTest. I use Quick and Nimble so the new XCTest needs to be imported by every dependency as well. I cannot use the package edit mode on a bundled package either.

You should be able to with a top level type alias to your custom Foundation library, combined with pre-processor directives to expose various target settings (in the form of #if canImport(Foo) or some other directive) if you wish.

But that requires me to edit AwesomeLibrary right? To change its imports and add the aliases there?

you should be able to typealias NotFoundation in outside of your library just fine too, have you tried?

I will try once I get back to my PC but wouldn't the library be compiled with the regular Foundation by SwiftPM, and then imported in my project? I can typealias all I want outside of the library it's not going to change it is it