isKindOfClass: returns false negative in unit test bundle

后端 未结 3 1494
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 11:55

So I have an instance of MyViewController in the detail view of a UISplitViewController. I am running a unit test to see whether the detail view contains the correct type of

相关标签:
3条回答
  • 2021-01-01 12:19

    Maybe this is helpful, first answer: isKindOfClass and NSStringFromClass disagree about UIApplicationDelegate.

    0 讨论(0)
  • 2021-01-01 12:20

    Had the same issue with one of my apps, fixed it by removing .m file from Test target. In your case removing MyViewController.m from the test target will fix your issue. Open your .m file .Go to right navigator in Xcode and remove the tick from Target membership for test target. Problem is compiler compiles two MyViewController.m (one for app one for test) and .class may return different object.

    0 讨论(0)
  • 2021-01-01 12:27

    As mentioned in my question, I realised I was incorrectly including the app's source files in the test bundle's compile sources build phase. After removing the source files from this build phase I solved the linker error of the missing symbols by changing the Symbols Hidden by Default build setting to "No" for the Debug configuration

    Xcode build settings

    This solved the linker error and meant that I was no longer including duplicate source files


    Note: Also, be sure to set the "Host Target" for the test target in the Info tab of Xcode so it'll pull the compile sources from there

    0 讨论(0)
提交回复
热议问题