SwiftPM and conditional compilation


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.