I'm trying to write UI & Unit Tests for an app we're working on. In order to make it easy, I've written a class that randomly instantiates objects from the project's classes, that can then be used by all the test classes.
The problem I'm encountering right now is that when building UI Tests, the Mach-o linker is throwing some errors saying Symbols not found for architecture ...
and referencing my project's main classes and that random object generator.
The weird thing is that, for Unit Tests, the same random generator works just fine !
For context: Doesn't matter if I run everything on actual device or simulator (so the architecture argument in the error is irrelevant)
My project is setup in the following manner:
Note that RandomObjectGenerator class is assigned to the following targets:
As such, my Unit/UI test classes always specify @testable import MyProject
.
Here's the error message thrown during compilation:
While in the editor, I can reference those classes just fine...
If anyone has any idea, I'd be glad to hear it. I'm kinda losing my mind to those errors :(
Your problem is not easily solvable at the moment... You gotta do crazy things to get around that limitation, such as: Include all your code in your UI test target.... or provide ways to access the logic you want exposed, from the UI Layer so it can trigger things inside your app. i.e. A Button that resets all your data layer... fakes network connectiviy... whatever your test is.
Check this answer for more details and the different strategies to solve that problem:
Linker error when accessing application module in UI tests in XCode 7.1