Swift Package Manger: "Use of Undeclared Type '<foo>'

Hi, all! I'm trying to set up a theme for John Sundell's 'Publish' static site generator. I'm following the advice of this blog post here, which is to say

  1. File > New > Swift Package
  2. Add publish as a dependency, e.g.
import PackageDescription

let package = Package(
    name: "FooTheme",
    products: [
        .library(
            name: "FooTheme",
            targets: ["FooTheme"]),
    ],
    dependencies: [
        .package(url: "https://github.com/johnsundell/publish.git", from: "0.5.0"),
    ],
    targets: [
        .target(
            name: "FooTheme",
            dependencies: ["Publish"]),
        .testTarget(
            name: "FooThemeTests",
            dependencies: ["Publish"]),
    ]
)

  1. Create Resources/FooTheme/styles.css
  2. Copy Sources/Publish/API/Theme+Foundation.swift from the Publish package to Sources/FooTheme/Theme+Foo.swift, updating references to the new theme
...
public extension Theme {
    static var foo: Self {
        Theme(
            htmlFactory: FooHTMLFactory(),
            resourcePaths: ["Resources/FooTheme/styles.css"]
        )
    }
}

private struct FooHTMLFactory<Site: Website>: HTMLFactory {
...
}

However, when I build the project, I get a cascade of Use of undeclared type errors, e.g. Use of undeclared type 'Theme' and Use of undeclared type HTMLFactory`, as if it's not actually importing the dependency.

I cleaned the build folder and deleted derived data, but no joy so far. I get the same result using Xcode 11.3 and 11.4 beta, and Swift 5.1.

For whatever it's worth, the project is here on GitHub.

Am I doing something obviously wrong? Thank you!

He just probably forgot to mention you need to import Publisher at the start of the Theme+Foo.swift file. You might want to inform him of that issue in his tutorial.

1 Like

Ah, thank you! Will do.