I'm using Unit Testing in XCode 4. I've been adding my application *.m files to the unit test target "compile sources" as I refer to them so the unit test will build/run.
Is there a better way here?
Note - I've just tried adding the application to the unit test target "target dependencies", but this didn't seem to work (still get some build errors).
Prior to Xcode 4, the approach you describe was necessary: An application test target had to essentially be a copy of your actual application, plus tests.
But with Xcode 4, we no longer need to do this for testing in the simulator. Instead, use a target that is a unit test bundle, and add your tests to the bundle. During testing, the application is launched, and the test bundle will be injected into and linked with the application, all at runtime.
Since it sounds like you tried this approach, let's discuss the actual errors you get.
Yes, you will need to add each and every .m file you need to your unit test target.
This will include them in the target compile and link phases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With