Robustly find the path to an executable target from within swift-testing

When running tests, the executable target isn't built as a separate product. Rather, its object files are linked into the test target which is run, depending on platform, as either a hosted bundle or as an executable.

The new #bundle macro in Foundation is the approximate replacement for Bundle.init(for:) but, if you have a class handy, Bundle.init(for:) will do what you need.

2 Likes