I'm looking for a way to build same source files into multiple libraries, but with different Swift Settings.
Let's say I have my sources under:
Then, I'd like to define targets like following:
.target( name: "MyLibWithFeatureA", path: "Sources/MyLib", swiftSettings: [.define("ENABLE_FEATURE_A")] ), .target( name: "MyLibWithFeatureB", path: "Sources/MyLib", swiftSettings: [.define("ENABLE_FEATURE_B")] ), ...
However, the compiler is throwing an error:
target 'MyLibWithFeatureA' has sources overlapping sources.....
What is the reason for this restriction and is there a way to workaround it?
I have a library that should conditionally integrate with a number of features. Ideally, users of the library would pass some configuration to the package dependency which features to enable, but I don't think SwiftPM supports anything like that.
Therefore, my idea is to expose the library as multiple libraries, each building from the same core, but with different combinations of features enabled. I know this doesn't scale well, but seems to be the only way at the moment.
MyLib target and then
MyLibWithFeatureA that depends on
MyLib is not possible in my case since code is not strictly additive. It would be possible to do that if
swiftSettings were applied to dependencies, but they are not