views:

2863

answers:

2

I followed Chris Hanson's advice about debugging framework unit tests in Xcode 3.1, but when trying to run the custom executable, the program crashes, stating the below error message [substituted $(BUILD_PRODUCTS_DIR) for the real location of the build products].

2009-03-02 19:56:03.414 otest[28059:10b] Error loading
    $(BUILD_PRODUCTS_DIR)/Debug/Unit Tests.octest/
    Contents/MacOS/Unit Tests: dlopen($(BUILD_PRODUCTS_DIR_)/Unit
    Tests.octest/Contents/MacOS/Unit Tests, 265):
    no suitable image found. Did find:
    $(BUILD_PRODUCTS_DIR)/Unit Tests.octest/Contents/MacOS/Unit Tests:
    mach-o, but wrong architecture
2009-03-02 19:56:03.561 otest[28059:10b] The test bundle at
    $(BUILD_PRODUCTS_DIR)/Unit Tests.octest could not be loaded because
    it is built for a different architecture than the currently-running
    test rig (which is running as unknown).
2009-03-02 19:56:03.568 otest[28060:203] *** NSTask: Task create for path
    '$(BUILD_PRODUCTS_DIR)/Unit Tests.octest/Contents/MacOS/Unit Tests'
    failed: 8, "Exec format error". Terminating temporary process.

My question is, what leads to the no suitable image found. Did find: ... error message and how can I get the otest executable to run correctly so that I can debug my framework unit tests?

Is there an easier way to do this with out using otest?

A: 

The line Unit Tests.octest could not be loaded because it is built for a different architecture than the currently-running test rig would suggest that the dependencies were built for a different system - perhaps it's a PPC / Intel mismatch or the like?

Andy Mikula
+2  A: 

otest is running just fine. The error is telling you that it can't load the test bundle, and that the reason why it can't load the test bundle is because it doesn't know what architecture it's running as.

The solution is to set ARCHPREFERENCE in otest's environment. You can do this in Xcode's custom executable editor. Set it to the architecture you want to run tests under.

Peter Hosey
Worked like a charm. Thanks, Peter!
Mike Caron