Running Swift Package unit tests in release configuration: @testable module was not compiled for testing

23 Views Asked by At

I would like to run unit tests in release configuration so that DEBUG is not specified. When I try to do this (from Xcode with an Xcode project file unlike in Run Swift Package tests in release mode in Xcode) I get a "module was not compiled for testing" build error for the module I've marked @testable (same as the linked question).

Is there a workaround I can use for the build scheme or configuration of my unit test target?

1

There are 1 best solutions below

0
Jon Reid On

To test anything in release builds, you'll need to make them public.

(In many languages, this is the only way for tests to access production code. Think of it as putting tests on the same playing field as any other external code.)