node-swift
node-swift copied to clipboard
Multiple modules / dynamic libs in the same package
I need to build several distinct NodeModules in the same project.
I have this directory structure
root
├ Sources
│ ├ Module1
│ │ └ Module1.swift
│ └ Module2
│ └ Module2.swift
├ package.json
└ Package.swift
And in Package.swift I declared my 2 .dynamic products and the 2 associated targets.
When I run node-swift build I get this error :
Error: Found more than 1 dynamic library in the Swift Package. Consider specifying which product should be built via the swift.product field in package.json.
I ended up patching cli.js to accept another command line argument specifying which product to build.
Is there some other way to achieve this ?
It would be possible to extend the CLI to support multiple products, but I think there are two simpler options:
- Expose both of your Swift API interfaces from a single module
- If you really want multiple
NodeModules, you can alternatively use a monorepo structure and create two child packages
Is there a reason either of these approaches doesn't work for you? Curious to know your use case.
1 is undesirable because separation of concerns: both products are too different 2 a monorepo is a bit overkill here and adds useless complexity
The use case is a node.js program with screen capture (product 1), image processing, and output in a native window (product 2)