How do iOS Unit/Application-Test targets link against classes from their host app?

Viewed 278

I'm currently trying to add unit tests (to be precise application tests) to my app (a reaaallly old project.. a comment says iOS 2.0) and always stumble upon undefined symbols for architecture when I try to test a class, which is within my hostapp. Since the obvious fixes didn't work yet, I want to understand the entire process in depth. It would be really appreciated if someone would shed some light :)

From what I have gathered so far:

  • Unit tests targets need a host app. This is specified in "TEST_HOST". Furthermore it is also specified in BUNDLE_LOADER.

  • Target to test needs to provide the symbols. So "Strip Debug Symbols During Copy" should be NO.

  • Taget to test needs to be enabled to test "Enable Testability" = YES

  • Some people need Post Deployment Processing set to NO

  • In the testtarget the hostapp should "allow testing host applications APIs"

When the linker links the test files, it searches somewhere (where exactly is this path specified) for the object files and symbols from the host app. Then after linking successfully it deploys the unit test "plugin" into the apps plugin folder and starts testing.

As you can see this is quite a rough understanding. So if you could add details (however miniscule) I would be really thankful.

1 Answers

I've just realized I haven't answered this question...

In my case the missing symbols was a result of compiling the libraries with visibility set to hidden. If that is the case, the tests are unable to find the symbols as the lib does not provide them to the public. Changing the compile command for testing to set the visibility to default made the difference.

Related