My unit tests worked fine in xcode4 until I had to create a new schema to compile a package to run on my device for testing.
All I did was creating a new Target an
We were using nodejs-mobile which would build with the app but fail building with the tests.
Undefined symbols for architecture x86_64:
_start_node
In addition to all of the previous answers (build settings, search paths, making a brand new Unit Test, deleting DerivedData), what finally resolved it was creating a brand new new UI test instead of a Unit Test in Xcode.
It built successfully. Then you can copy your test definitions from your current test to the one one.
If you do not need the UI part, you can uncomment XCUIApplication().launch()
in setUp
of the generated tests, which makes it run as fast as before.
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.
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/).
Same error message, in my case I wasn't linking one of the classes that were needed during the tests.
I discovered my problem was that I had 'Link time optimisation' enabled on my debug build. Setting it to no resolved the problem.
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.