In Xcode 14, there seem to be two ways to configure how any particular piece of source code from the app module is available in a test target:
- Add the source file to both the app target and the test target
- Add the source file only to the app target, import the app module into each test class, and configure the test target to run use the app as the Host Application (including checking the 'Allow testing Host Application APIs' checkbox)
Going with the first method seems to be better in my testing, as it produces a much faster run time. Option (2) when using the default (and very much desired) parallelization setting causes multiple simulator launches, which slows things down terribly.
The downside of option (1) is that we'll be compiling source files twice. We really want to be testing precisely what was compiled in the app module, but it seems the lesser issue to contend with.
So, neither of these options seem ideal to me – what we really want is a dumb anonymous test target that simply links to the compiled app module. This would avoid the extra compile step, allow me to avoid using a Host Application, and test precisely what's compiled into the app module.
Am I missing something, or is there no way to achieve this?