So I'm using XCTest to make some tests for my iOS app. Most of my code is c++ and most of my objective-c files are objective-c++ including my test files. XCode doesn't really like this in that is breaks the code highlighting of the XCTest asserts etc, but it runs and works fine. I need to add extra data and functions to help with the tests. I make my data include an expected results stream as well that is read in for the test cases to check against, and I will have some extra print functions so when a test fails it can show me the final state of the test object that failed or out put extra info to help me see where it went wrong or help me understand exactly how it fails.
I have no use for these functions and data in the "normal" version of the app, and hence no code in my app will reference these functions or data structures and hence LLVM does the right thing and strips them from my code.
XCTest while being another Target and having its own build settings seems to compile the base target with their settings and then compile its own code with its settings, so if I set the Dead Code Stripping compile option to No in XCTest project it still strips the dead code in the base project. This then causes the XCTest compile to fail. As the Linker can't find the methods that were dead stripped.
At the moment I have all the test specific extra code made with a custom #define so it is compiled in when XCTest is built, but to ensure that the code is not deadstripped I need to find some random place in the code that I know won't be run under the test where I can add some code to use the functions and data structs in a way that won't optimised out by the compiler.
Is there a Pragma or other flag I can use that allows me to instruct the compiler not to remove this function/data struct that I can put inside the define as well? e.g
#ifdef TEST
#pragma DONT_STRIP
int* getSpecialTestData(int item) { ... }
#endifor a per file level don't strip, so I can pull all the test code in to a sperate file that is conditionally imported/included?