Closed thannn closed 6 months ago
Could you share the Package.swift file?
In theory, .testTarget
should be something like this:
.testTarget(
name: "PrefireExampleTests",
dependencies: [
"PrefireExample",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
plugins: [
.plugin(name: "PrefireTestsPlugin", package: "Prefire")
]
)
Sure, here's the Package.swift
:
let package = Package(
name: "Redacted",
platforms: [
.iOS(.v15)
],
products: [
.library(name: "Redacted", targets: ["RedactedUI", "RedactedUIKit", "RedactedSwiftUI"]),
.library(name: "RedactedUI", targets: ["RedactedUI"]),
.library(name: "RedactedUIKit", targets: ["RedactedUIKit"]),
.library(name: "RedactedSwiftUI", targets: ["RedactedSwiftUI"])
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.12.0"),
.package(url: "https://github.com/BarredEwe/Prefire", from: "1.0.0")
],
targets: [
.target(name: "RedactedUI", ...),
.target(name: "RedactedUIKit", ...),
.target(name: "RedactedSwiftUI", ...),
.testTarget(
name: "RedactedTests",
dependencies: [
.target(name: "RedactedUI"),
.target(name: "RedactedUIKit"),
.target(name: "RedactedSwiftUI"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
],
plugins: [
.plugin(name: "PrefireTestsPlugin", package: "Prefire")
]
)
],
swiftLanguageVersions: [.v5]
)
You need to add Prefire dependency for the testTarget:
.testTarget(
name: "RedactedTests",
dependencies: [
.target(name: "RedactedUI"),
.target(name: "RedactedUIKit"),
.target(name: "RedactedSwiftUI"),
"Prefire",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
],
plugins: [
.plugin(name: "PrefireTestsPlugin", package: "Prefire")
]
)
🤦 I'll have to up my SPM knowledge. That'll do, I can move along. Thank you!
Context 🕵️♀️
Attempting to generate snapshot tests.
Using #Preview for SwiftUI previews.
.prefire.yml:
What 🌱
The generated code (PreviewTests.generated.swift) throws error
No such module Prefire
upon lineimport Prefire
.