views:

442

answers:

3

I'm trying to setup application unit tests for my iphone app. So I made a copy of the app target, and a unit test bundle target as described in apple's documentation (http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html)

After following Apple's directions, I wasn't able to reference my classes in the unit tests, so I linked the app into the unit test bundle using the "Bundle Loader" build setting and setting the main target to export symbols. That resolved the compilation time errors, and it worked and executed my tests immediately after I changed it. But once I cleaned and built again, I started getting this error when I tried to run on the device:

Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1 (7C144)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection" (file not found).

It's true that the file doesn't exist. I found the .framework file under: /Xcode3.1.4/Library/PrivateFrameworks PrivateFrameworks

and made a symbolic link. Then running the app said that it couldn't link the app's files:

010-01-25 20:19:22.330 SmokeyTheBear[5808:207] Error loading /private/var/mobile/Applications/26E1F8F4-6444-415B-84CB-BB161DBA29E9/SmokeyTheBear.app/LogicTests.octest/LogicTests:  dlopen(/private/var/mobile/Applications/26E1F8F4-6444-415B-84CB-BB161DBA29E9/SmokeyTheBear.app/LogicTests.octest/LogicTests, 262): Symbol not found: _OBJC_CLASS_$_AppDelegate
  Referenced from: /private/var/mobile/Applications/26E1F8F4-6444-415B-84CB-BB161DBA29E9/SmokeyTheBear.app/LogicTests.octest/LogicTests
  Expected in: /var/mobile/Applications/26E1F8F4-6444-415B-84CB-BB161DBA29E9/SmokeyTheBear.app/UDorse
 in /private/var/mobile/Applications/26E1F8F4-6444-415B-84CB-BB161DBA29E9/SmokeyTheBear.app/LogicTests.octest/LogicTests
DevToolsBundleInjection: Error loading bundle '/private/var/mobile/Applications/26E1F8F4-6444-415B-84CB-BB161DBA29E9/SmokeyTheBear.app/LogicTests.octest'

Then, I switched back to running the normal target for the app, and it ran all my unit tests and exited! I cleaned again and built, and then the normal target ran normally. The unit test target still didn't work.

A: 

How are you linking the framework in the first place? You shouldn't have to create a symlink in order to make it work. Switch to your test bundle target and open Project->Edit Active Target. Make sure the library is in the 'Linked Libraries' section of the general tab. If it is, remove/re-add it. This has fixed similar issues with library linking for me.

Ben
You weren't really specific enough for me to understand what you mean. When you say framework, do you mean the senstesting or the devtoolsbundleinjection? None of the documentation mentions specifically linking the devtoolsbundleinjection, and it seems weird that it's in the wrong folder, and that it briefly worked. Regardless, I've tried linking sentesting and devtools in both the unit test bundle and the app target and every combination possible. And if it compiles, I get the same result as above, depending on if the symlink exists or not.
smokey_the_bear
Gotcha better now, it's a different problem that I was trying to answer at first. (looked like it was just another .framework you were including in linked libraries for the target)Have you checked your DYLD_INSERT_LIBRARIES and DYLD_FALLBACK_FRAMEWORK_PATH environment variables?From here: http://chanson.livejournal.com/120740.html?thread=366500
Ben
Yeah, that was written before xcode included the unit testing framework for apps, so it autogenerates them now. But I've tried tweaking them to exactly what he suggests, and giving absolute paths. Same result.
smokey_the_bear
Out of ideas then, sorry. I'd be trying from the start of the instructions again and creating a new target, making sure it's using the right iPhone OS version, etc. but you've likely already tried that.
Ben
Yeah, I've tried that repeatedly, and tried using the GTM unit test wrapper too. Keep getting stuck. Thanks for trying.
smokey_the_bear
A: 

Hey smokey_the_bear, have you checked what I went through with this question:

http://stackoverflow.com/questions/1713280/linker-error-iphone-unit-test-bundle-referencing-app-classes

Ihad to specify the bundle loader to get things linking properly.

ohhorob
Hi Ohhorob. As I said in my question, I specified the Bundle Loader, which allowed it to compile. But at run time the debug console reports that it cannot find the app delegate and other files the tests use.
smokey_the_bear
A: 

Have you tried the power of prayer?

Andrew Johnson