xcode 4 fails to initiate unit tests (with linker error) after I created a new scheme xcode 4 fails to initiate unit tests (with linker error) after I created a new scheme ios ios

xcode 4 fails to initiate unit tests (with linker error) after I created a new scheme


Like @Haoest and @Peter DeWeese above's comments to Answer 1 - I had exactly the same problem when I changed the product name.

To fix this for the case where you've renamed the product, you need to go to the Build Settings tab of the test target, and change the Linking section - the Debug and Release bundle loader settings. If you have renamed the product - the directory and name of the application may both be incorrect.

Thanks to both of them for pointing this out - but I thought this alternative fix for this situation deserved a higher profile than a comment.


I've also run across problems with Xcode 4 after adding a target to an existing project. I eventually figured out that the Xcode DerivedData for the project was damaged. By deleting that data, I caused Xcode to rebuild the data and the project returned to normal. I found the data in my home Library folder (~/Library/Developer/Xcode/DerivedData/).


I tried everything (including the other answers and those noted here http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/), but finally found a different solution:

Set Deployment Postprocessing (in the Deployment section of Build Settings) to NO for the Debug target.

Before I did this, the executable was being stripped, and the link would fail with

Undefined symbols for architecture i386:  "_OBJC_CLASS_$_SomeClassUnderTest", referenced from:      objc-class-ref in SomeTest.o

No matter that Strip Linked Product and Strip Debug Symbols During Copy were set to NO, it made no difference - only changing the Deployment Postprocessing setting finally made sure that the symbols were not stripped.