Hey Xcode Users, I’m trying to create a static library to pull some lower level objects out of my App and in to a common framework, but I’m running in to an issue that is confusing my unit tests. Setup:
- A static library which contains the class WFRoutines
- A .app which links against the static library
- A test target for the .app which links against the static library as well
When I run the tests it looks like there are two instances of the classes provided by my library:
(lldb) p (char *)class_getImageName([WFRoutines class]) (char *) $0 = 0x00007fff5c2de6c0 "/Users/nick/Library/Developer/CoreSimulator/Devices/70F1F59A-4AFC-4326-BD65-86BA64D87151/data/Containers/Bundle/Application/B592876B-DD27-4A68-9BD3-C187C15DB7A0/Wealthfront.app/Wealthfront" (lldb) p (char *)class_getImageName(aClass) (char *) $1 = 0x00007fe9db70bb90 "/Users/nick/Source/Builds/Test-iphonesimulator/WealthfrontTests.xctest/WealthfrontTests”
This is only a problem for me because I am trying to create a mock object based on this class, and it appears that this line of code does something completely different from what it does in the debugger:
id mockRoutines = [OCMockObject mockForClass:[WFRoutines class]];
As you can see above the debugger believes [WFRoutines class] lives in the .app, however whats not what actually gets passed to OCMock.
Is there some linker magic I can apply to get these two things to align on the same runtime object? Or does OCMock need to be modified to work its magic on all available class instances?
Thanks much.
Nick |