I’ve recently stumbled upon severe issues, while trying to write a Unit Test, in Swift, that would access Swift Code that belongs to the main app.
Contrary to what almost everyone mentions, you should not import the Main App’s files into the Testing target.
Instead, this is what you should do:
- Enable Defines Module in the main target.
- Add an import at the top of the Unit Test, to make the main project visible.
- Make sure that the classes to be tested are set to public.