I found myself re-architecturing a project, and I have to split the test module in two: TestModuleA and TestModuleB, where TestModuleA depends on TestModuleB.
Since this is not production code, I thought I could avoid many source code changes by doing the following from inside TestModuleA:
@_exported @testable import TestModuleB
But seems like the @testable is not considered when using @_exported, which forces me to make big source code changes: not use @_exported and instead add @testable import TestModuleB in almost all files of TestModuleA.
Is there any other alternative? Is there a way to make @_exported @testable import TestModuleB work as expected? Maybe by passing custom build settings to the complier?
@testable exposes internal interface of the imported module to the importing module. Why would you want access to TestModuleB? I assume it would contain tests only and any utility functions/classes would be separated into yet another Utilities module.
Also for @testable to work you'd have to compile the imported module with testing enabled (quote from Swift book):
<...> a unit test target can access any internal entity, if you mark the import declaration for a product module with the @testable attribute and compile that product module with testing enabled.
@testable exposes internal interface of the imported module to the importing module.
Yes.
Why would you want access to TestModuleB ? I assume it would contain tests only and any utility functions/classes would be separated into yet another Utilities module.
TestModuleB is what you call Utilities: it contains utilities I need in TestModuleA and in other modules.
Also for @testable to work you'd have to compile the imported module with testing enabled (quote from Swift book):
Yes. Testing is enabled by default in all DEBUG targets when using Xcode.
I understand that I am not answering your question, but I wonder if this approach would make sense to you too
Thanks for the answers I am aware that there is a way around it: add @testable import TestModuleB in every file of TestModuleA. But I would like to avoid it, that is why I am asking about the possibility of using @_exported @testable import TestModuleB