i was also having problems with setting up application tests in xcode4.
A solution that worked for me was as follows:
Assuming you have an application target called "MyApp"
- Add a new target of type "other/Cocoa Unit Testing Bundle" to the project e.g "MyAppTesting". Here all Unit test files are located.
- Go to MyAppTesting Build Phases and add MyApp as Target Dependency. This assures that MyApp is build before building the MyAppTesting target.
- Open the Build Settings of MyAppTesting and change
- Bundle Loader: $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp
- Test host: $(BUNDLE_LOADER)
That causes the tests to run within MyApp.
- Open the Build Settings of MyApp and change
- Symbols Hidden by default: NO (for both)
- Strip debug Symbols during Copy: Debug:NO
By doing so you do not have to include every .m-file into the test target.
To run the test on a device plugin the device and select the scheme "MyAppTesting on device" and run as test. Assure that the mentioned scheme has set "Debug" within Test/Build Configuration which should be default.
Best regards.