Hello, I am trying to build two libraries which share common code, preferably having a subfolder with the shared code and another with the code that is target specific.
I was looking for something like the following, but the syntax seems to make it so you can only have one path.
let package = Package( name: "Cores", platforms: [ .iOS(.v12), .macOS(.v10_14) ], products: [ .library( name: "ACore", targets: ["ACore"] ), .library( name: "BCore", targets: ["BCore"] ) ], targets: [ .target( name: "ACore", path: ["Sources/Common", "Sources/ACore"] // NOT VALID SYNTAX, what I was looking to do ), .target( name: "BCore", path: ["Sources/Common", "Sources/BCore"] // NOT VALID SYNTAX, what I was looking to do ), )
Also, when I try to do something like this I get "has sources overlapping sources" as the error message. I could put the common code in a "CommonCore" library but then I have lots of modules and this may have performance implications. Is the common library approach the recommended way of doing this? Using a common library means that now users of the library must use a different module for the shared code. So they would have to
import ACore and
import CommonCore. This is undesirable.