Xcode 4 unit testing linker error

后端 未结 9 846
小鲜肉
小鲜肉 2021-02-05 09:19

NOTE: \"Use GHUnit\" is not an acceptable answer to this question. I know most think GHUnit is better than the Xcode4 OCUnit, but that\'s not what I\'m asking about. I\'ll evalu

相关标签:
9条回答
  • 2021-02-05 09:56

    I had this same problem once. For some reason one of the source files for my project was also included to be compiled for the test target, which causes this link error.

    By making sure that only the test-implementation files are compiled, you should be able to resolve this error. You can check this at:

    TestTarget -> Build Phases -> Compile Sources

    0 讨论(0)
  • 2021-02-05 10:00

    I had to set the "Test Host" property on the unit test target to $(BUNDLE_LOADER). That solved my problem!

    0 讨论(0)
  • 2021-02-05 10:00

    I just wasted hours on this and similar errors - turns out I had renamed my main target - attempts to fix this by renaming the relevant variables and by removing the entire DerivedData directory were unsuccessful.

    I eventually simply set up a new unit test target following the steps here: http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/

    And everything is fine now.

    So - if you have strange, inexplicable link errors you might be better off just creating a new unit test target. Only takes 2 minutes.

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