xcode 是什么导致在 Mac OS X 上找不到合适的图像错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/617084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:30:00  来源:igfitidea点击:

What leads to a no suitable image found error on Mac OS X?

objective-ccocoaunit-testingxcodedebugging

提问by Mike Caron

I followed Chris Hanson's adviceabout 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].

我遵循了 Chris Hanson关于在 Xcode 3.1 中调试框架单元测试的建议,但是当尝试运行自定义可执行文件时,程序崩溃,并指出以下错误消息 [用 $(BUILD_PRODUCTS_DIR) 替换构建产品的真实位置]。

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 otestexecutable to run correctly so that I can debug my framework unit tests?

我的问题是,是什么导致找不到合适的图像。是否发现:...错误消息以及如何让otest可执行文件正确运行,以便调试我的框架单元测试?

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

有没有更简单的方法来做到这一点而不使用 otest?

回答by Peter Hosey

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.

otest 运行良好。该错误告诉您它无法加载测试包,并且它无法加载测试包的原因是因为它不知道它正在运行的架构。

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

解决办法是ARCHPREFERENCE在otest的环境中设置。您可以在 Xcode 的自定义可执行编辑器中执行此操作。将其设置为您要在其下运行测试的架构。

回答by Andy Mikula

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

该行Unit Tests.octest could not be loaded because it is built for a different architecture than the currently-running test rig表明依赖项是为不同的系统构建的 - 也许是 PPC / Intel 不匹配等?