iphone:无法将 gh-unit 目标链接到应用程序目标,无法执行二进制文件

发布于 2024-12-17 07:35:29 字数 1279 浏览 1 评论 0原文

这是一个试图完成本教程< /a> 提供 GHUnit 测试目标。它是将测试目标链接到源目标,以便您不必手动将源文件包含在测试目标中。以下是所提出的解决方案的摘录。

使用 Xcode 4 将单元测试添加到现有 iOS 项目

项目 MyExistingApp -> + 添加目标 -> iOS->其他->可可单元测试包

将新目标命名为“Unit Tests”或“MyAppTests”

选择新的“单元测试”目标,然后单击“构建阶段”选项卡,展开“目标”

依赖项并将 MyExistingApp 添加为目标依赖项

单击“构建设置”选项卡并将“捆绑包加载器”设置设置为

$(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp

将测试主机构建设置设置为

$(BUNDLE_LOADER)

在您的应用目标中,将默认隐藏的符号构建设置设置为

我按照教程使用 GHUnit 测试目标进行编译,但是我收到运行时错误:

warning: This configuration supports "Darwin64" but is attempting to load
an executable of type i386 which is unlikely to work.
Attempting to continue.
`/usr/lib/dyld' has changed; re-reading symbols.
warning: Inconsistent DBX_SYMBOL_SIZE

/Users/...Tests.app/Tests: /Users...Tests.app/Tests: cannot execute binary file

感谢您的帮助!

编辑

我意识到上面发布的教程和使用 GHUnit 有一个问题。上面的教程假设您正在使用 OCUnit,它将启动捆绑加载器目标。然而,GhUnit 目标必须是可执行文件。如果有人想分享如何将源文件链接到可执行目标,我将不胜感激。现在,我将使用 GHUnit 手动完成所有操作。

this is a question that tries to accomplish what this tutorial offers with a GHUnit Test Target. Its about linking a test target to the source target so that you dont have to manually include the source files in the test target. The following is an excerpt of the solution proposed.

Adding Unit Tests to an existing iOS project with Xcode 4

Project MyExistingApp -> + Add Target -> iOS -> Other -> Cocoa Unit Testing Bundle

Name the new target something like “Unit Tests” or “MyAppTests”

Select your new “Unit Tests” target and click the Build Phases tab, expand Target

Dependencies and add MyExistingApp as as a Target Dependency

Click the Build Settings tab and set the Bundle Loader setting to

$(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp

Set the Test Host build setting to

$(BUNDLE_LOADER)

In your app target, set the Symbols Hidden by Default build setting to

NO

I get it to compile with a GHUnit Test Target following the tutorial, but I get a runtime error:

warning: This configuration supports "Darwin64" but is attempting to load
an executable of type i386 which is unlikely to work.
Attempting to continue.
`/usr/lib/dyld' has changed; re-reading symbols.
warning: Inconsistent DBX_SYMBOL_SIZE

/Users/...Tests.app/Tests: /Users...Tests.app/Tests: cannot execute binary file

Appreciate your help!

EDIT

I realize that there is a catch with the tutorial posted above and using GHUnit. The tutorial above assumes you are using OCUnit, wich launches a bundle loader target. The GhUnit target must however be an executable. If somebody wants to share how to link source files to an Executable target Ill appreciate it. For now, im going to do everything manually with GHUnit.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

物价感观 2024-12-24 07:35:29

不确定这是否是正确的答案,但它对我有用:

我得到了 GHUnits 测试用例,并用 SenTestCases 包装它们。 XCode 自动调用 SenTestsCases,所以我运行测试没有遇到任何麻烦。

工作起来就像一个魅力,让我的异步测试不再有任何后顾之忧。

Not sure if this is the RIGHT answer, but it worked for me:

I got the GHUnits testcases, and wrapped them with SenTestCases. XCode automatically calls SenTestsCases, so I didn't any trouble to run the tests.

Worked like a charm, got my async tests without any more worries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文