2011년 8월 1일 월요일

Setting Unit Test on Device

I'm trying to add unit tests to an existing universal app in Xcode 4. I've followed the tutorials and while the logic tests run fine in the simulator, when I try to test on device I get a dialog saying "Logic Testing on iOS devices is not supported. You can run logic tests on the Simulator." However, I've noticed that when you create a new project in Xcode 4 and check the Include Unit Tests box, it will actually install and run the tests on device. Am I missing an option somewhere that would allow me enable that on my existing project?

link|improve this question

Was this post useful to you?

I think I figured it out by going line by line through the Build Settings for the Cocoa Touch Unit Testing Bundle.

Build Settings

Linker

  • Set Bundle Loader to $(BUILT_PRODUCTS_DIR)/[Your App Name].app/[YourAppName]

Unit Testing

  • Set Test Host to $(BUNDLE_LOADER)

Build Phases

Add the application target to the Target Dependencies.

Once you do all that, you can just hook up your device and hit Test.