In that case SwiftPM complains that multiple targets contain the same source files.
I think this error is deliberately the case because for C targets, it would result in name clashes that would be confusing to debug, since the duplicate names would both be pointing at the same thing.
Since Swift symbols are namespaced by module, it might be possible to lift this restriction for Swift targets. But there could be some other reason I’m unaware of.
It’s a shot in the dark, but can you fool SwiftPM by “duplicating” the files with symlinks?
Remember though, that even if it works, MyPackageFeatureA.MyStruct will not be the same type as MyPackageFeatureB.MyStruct, even though they shadow each other. For many use cases, that would cause more nuisance than it solves.
I have Xcode targets setup just like this. There are several targets in the project. The source code files are the same for all the targets. I have #defines in the target settings that are different between the various targets. This is also how DEBUG and RELEASE builds work. The different targets generate different binaries.