Makaronodentro
Makaronodentro

Reputation: 957

Swift Package Manager, adding local dependencies

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?

Upvotes: 4

Views: 1443

Answers (1)

tanner0101
tanner0101

Reputation: 4065

You also need to declare Module1 and Module2 as targets.

targets: [
    Target(name: "App", dependencies: ["Module1", "Module2"]),
    Target(name: "Module1"),
    Target(name: "Module2")
],

Upvotes: 4

Related Questions