Circular dependency between modules 'ModuleTypes' and 'SnapshotTests'
Closed this issue · 5 comments
Swift package:
let package = Package(
name: "ModuleTypes",
platforms: [.iOS(.v15)],
products: [
.library(
name: "ModuleTypes",
targets: ["ModuleTypes"]
)
],
dependencies: [
.package(path: "../Asset"),
.package(path: "../Common"),
.package(path: "../Components"),
.package(url: "https://github.com/BarredEwe/Prefire.git", branch: "main"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.11.0")
],
targets: [
.target(
name: "ModuleTypes",
dependencies: [
"Prefire",
.product(name: "Assets", package: "Asset"),
.product(name: "Common", package: "Common"),
.product(name: "Components", package: "Components")
],
path: "./",
exclude: ["Tests"],
plugins: [
// For Snapshot Tests
.plugin(name: "PrefireTestsPlugin", package: "Prefire")
]
),
.testTarget(
name: "SnapshotTests",
dependencies: [
"ModuleTypes",
.product(name: "TestAssets", package: "Asset"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
]
)
]
)
Appears that mainTarget
is incorrectly resolving to my test target.
Strange when it seems to be: context.package.targets.first
Hello!
Yes, you are right. I can use your fix and make a pull request, or you can create pull request it yourself (since you already fixed the problem). 😊
I think the problem is adding the plugin for tests not in the test target.
.testTarget(
name: "SnapshotTests",
dependencies: [
"ModuleTypes",
.product(name: "TestAssets", package: "Asset"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
],
plugins: [
// For Snapshot Tests
.plugin(name: "PrefireTestsPlugin", package: "Prefire")
]
)
But still, I added some checks to get the mainTarget
#14
Think you may be right @BarredEwe - I'll have another go. Still right to not assume targets.first
is main target.
I think, filtering your own target name (this fix was added in the latest release) and connecting the plugin to testTarget can fix this problem.
@markst Could you try the latest release?