Question or problem
Using the swift-dependencies
package (which is included transitively from TCA), when adding a dependency on the DependenciesTestSupport
product to a test target, there’s a build failure.
The build failure is in the IssueReportingTestSupport
library in the xctest-dynamic-overlay
package, which is a dependency of DependenciesTestSupport
.
It’s in the file XCTest.swift
.
This file adds functionality for when XCTest
is available, and there’s a check at the top of the file #if canImport(XCTest)
, which appears to succeed as the following code is not greyed out.
However, the code in canImport
attempts to access XCTest
functions like XCTFail
and cannot find them. This is the build failure.
Looking at the IssueReportingTestSupport
target, it doesn’t have XCTest
as a dependency. Adding it appears to resolve the build failure.
Now I’m using Swift Testing and Swift 6, and since XCTest
isn’t a dependency of IssueReportingTestSupport
, I wouldn’t even expect #if canImport(XCTest)
to succeed and attempt to access XCTest
functions.
So I’m not sure what I expect here. If canImport(XCTest)
could fail somehow, then Tuist’s behavior of not linking against XCTest
would be correct.
Expectation
Adding
DependenciesTestSupport
as a test dependency should build fine.
Context
- Tuist version: 4.37.0
Reproduction (mandatory for problems)
Add the swift-dependencies
package to a project
Create a target with a test target
Add DependenciesTestSupport
as a dependency of the test target
Create a test with Swift Testing, import DependenciesTestSupport
and try to run it
Building the test target fails