I'm in the process of porting a fairly large codebase from Java to server-side Swift 4. The code itself will be developed on macOS, but eventually deployed on Linux. I have created separate module projects using the Swift Package Manager. Several of these are library projects, with the final being an executable to tie them all together to launch. I've generated Xcode project files for each module so that I can easily develop in Xcode, and I've created an Xcode Workspace to group them all together into one view.
My problem is, how do I indicate dependencies between these local modules? My executable module will obviously depend on all of the library modules. How do I represent this in my Package.swift file? I've tried something like this...
let package = Package(
name: "MySwiftExe",
dependencies: [
//.package(url: "../MySwiftLib", from: "1.0.0"),
...
But that fails to build. Is there a way to specify dependencies located on the same filesystem? Or am I required to grab the dependencies from Git?
Your URL can be relative, so ../MySwiftLib is perfectly valid. However, the source directory must be a git repository. It is recommended that this repo be tagged, but you can also do:
.package(url: "../MySwiftLib", .branch("master"))
if you want to use whatever code is on the master branch.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With