• 1

Worked fine with Xcode 2.4 but not working with Xcode 3

Hi Chris

Thanks for posting this guide. It has been very helpful to me in the past but that solution stopped working when I upgraded to Xcode 3.

I get an error stating that the DevToolsBundleInjection cannot be found or loaded. I have DYLD_INSERT_LIBRARIES set to $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection. I haven't changed it when I upgraded to Xcode 3.

My project use Xcode 2.4 compatibility mode and the target SDK is Mac OS X 10.4(Universal) as I dare not switch to Objective-C 2 for the moment for fear that OCUnit or OCMock will stop working entirely.

Would you have an idea about how to solve this by any chance?

Re: Worked fine with Xcode 2.4 but not working with Xcode 3

Hi Eric,

With XCode 3, you can do this in another way:

create a new executable and put the the path to 'otest'

Put as argument your unit test bundle name including the octest suffix.
(like MyTests.octest)

The rest can stay 'default'

option (right) click on the executable to run, or run with breakpoint.
This works for me.

Please note that if you have a garbage collection only app (objc 2), the otest binary can't handle that. If so, you need to fetch the OCUnit sources and build it with garbage collection supported (only the otest binary)

Re: Worked fine with Xcode 2.4 but not working with Xcode 3

This is not correct; Eric's question was about debugging application unit tests, whereas your instructions are for debugging framework unit tests.

Furthermore, you do not have to download OCUnit from Sen:te and build your own otest from their sources to run tests with garbage collection enabled. You do have to create your own test rig, but you can do that very straightforwardly by just creating a Foundation Tool that links SenTestingKit.framework, sets the SenTestTool user default to YES, and invokes SenSelfTestMain(); both of these are declared in <SenTestingKit/SenTestProbe.h>.

I'll document this in one of my posts on Xcode 3 unit testing.

Re: Worked fine with Xcode 2.4 but not working with Xcode 3

All of the developer tools - including their frameworks - are self-contained in the Developer folder as of Xcode 2.5 and Xcode 3.0 so that it can be moved and renamed at will, and coexist with other versions of the developer tools. There are two things you need to add to your executable to debug your application unit tests under Xcode 3.0.

First, you need to change your DYLD_INSERT_LIBRARIES to refer to $(DEVELOPER_LIBRARY_DIR) rather than $(SYSTEM_LIBRARY_DIR). (You'd also need to do this step under Xcode 2.5.)

Second, you need to add a new environment variable, DYLD_FALLBACK_FRAMEWORK_PATH, to your executable and set its value to "$(DEVELOPER_LIBRARY_DIR)/Frameworks:$(DEVELOPER_LIBRARY_DIR)/PrivateFrameworks" (without the quotes).

The second step is necessary because in order to support moving and renaming the Developer folder, the Xcode frameworks are linked using a new dyld feature called runpaths and have an install-name that starts with @rpath. Without the DYLD_FALLBACK_FRAMEWORK_PATH setting, Xcode will not necessarily be able to locate SenTestingKit.framework because your application doesn't necessarily define any runpaths that @rpath will resolve to (much less runpaths that contain SenTestingKit.framework).

I'm going to update and re-post the unit testing articles specifically for Xcode 3 at some point in the near future that point out these issues. Keep an eye out for that.

Re: Worked fine with Xcode 2.4 but not working with Xcode 3

One more thing... for me to get this working on Leopard, I needed to add 'set start-with-shell 0' to my ~./.gdbinit file. Chris is actually the source (via xcode mailing list) of that info, but I figured it would be good to add that here also.

Re: Worked fine with Xcode 2.4 but not working with Xcode 3

Thank you very much for all the help.

I was finally able to get everything working again. In the end, I had to add the DYLD_FALLBACK_FRAMEWORK_PATH as Chris suggested and to add "set start-with-shell 0" to my ~./.gdbinit file as someone else kindly suggested.

I also had to remove $(BUILT_PRODUCTS_DIR) from my XCInjectBundle environment variable. I'm still not sure why though, but it works.


  • 1

Log in