Hello, I would like to have the "build for testing" / "enable testability" flag be propagated to the local packages dependencies of my app when I build the unit tests target.
In the end, I'd like to have @testable import MyLocalPackage
next to @testable import MyApp
. Right now if I try to do that, Swift tells me that "MyLocalPackage was not build for testing".
Is that possible ? Could I just enable testability for all local packages in debug configuration in their Package.swift
, or is it a compiler flag?
2 Likes
Wondering if you ever found a solution? Or if anyone knows a 2024 (Xcode 16?) solution?
I am facing the same issue trying to include a local package's test target/plan into the main app's test plan.
No matter how I seem to include the local package's test target into the main apps scheme/plan etc., I always get the dreaded "Module '…' was not compiled for testing". Opening the local package standalone and running the tests works fine, I just can't seem to integrate them to run in conjunction with the main app's tests.
@kafermeister no I never found a solution. The proper way is to test each target in a separate test target (instead of testing everything in a single giant test target). Which is made difficult for us by Xcode / test plans.
Moving over to swift-testing and/or Tuist might make it easier to split tests in multiple targets.
2 Likes
Any news now with SwiftTesting? We also use TestPlans and have some local packages which we'd like to test by running the main test target. But this turns out to be unsatisfyably complicated...