Wednesday, January 2, 2013

GHUnit: Unable to Test Target Application Classes

I've started looking into GHUnit for Unit/API testing for iOS applications, and am having difficulty using it to test an existing application's classes. I have a GHUnit test target, TestGH, which I'd like to use to test classes in my application, TestApp. I'm using Xcode 4.5 and trying to run TestGH on iPad 6.0 Simulator. I believe I've configured the TestGH build correctly in the Build Settings and Build Phases. I've set the Target Dependencies to "TestApp" I've added the *.m files for the classes I'd like to test--along with the test case classes which will test them--to the Compile Sources section TestGH. Other notable configuration: In the app target, TestApp:
Symbols Hidden By Default: No Product Name: TestApp In the test target, TestGH:
Bundle Loader: $(BUILT_PRODUCTS_DIR)/TestApp.app/TestApp Mach-O Type: Bundle Other linker flags: -ObjC, -all_load Product name: TestGH Test Host: $(BUNDLE_LOADER)
I suppose I have this mostly right, as I discovered these settings by fighting through compile/link errors, reading stackoverflow, and blogs. However, when I launch TestGH, the Log Navigator shows: error: failed to attach to process ID 2305 (2305 corresponds to 'sh' according to activity monitor, fyi) Simulator screen remains black, and Xcode shows "Attaching to TestGH" in the status. Any ideas? I've gone through many suggested fixes/workarounds I've seen discussed here related to "failed to attach to process." Deleted DerivedData folder in Library/Developer/Xcode, deleted everything under Library/Application Support/iPhone Simulator. Tried all the options under Product->Edit Scheme for the TestGH target--tried Debugger = GDB, LLDB, None, Launch = Automatically, wait. Results are always the same. I've shared this on stackoverflow, if anyone wants to comment there: http://stackoverflow.com/questions/14073252/ghunit-target-failed-to-attach-to-process