In a vapor project, my folder structure is the following:
Package.swift
Sources/
-App/
-Module1/
-File1.swift
-File2.swift
-File3.swift
-Module2/
-File4.swift
-File5.swift
-File6.swift
After adding the 2 modules in each one of them, I edited the package.swift file to be the following:
let package = Package(
name: "myapp",
targets: [
Target(name: "App", dependencies: ["Module1", "Module2"])
],
dependencies: [
// Some external dependencies
],
exclude: [
// Excludes
]
)
Importing the 2 local modules works fine, yet when I try to use any functions / objects contained within them I get an "unresolved identifier error"
Anything I am missing?
You also need to declare Module1
and Module2
as targets.
targets: [
Target(name: "App", dependencies: ["Module1", "Module2"]),
Target(name: "Module1"),
Target(name: "Module2")
],
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