Xcode 4单元测试链接器错误 [英] Xcode 4 unit testing linker error

查看:143
本文介绍了Xcode 4单元测试链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:使用GHUnit不是这个问题的可接受答案。我知道大多数人认为GHUnit比Xcode4 OCUnit更好,但这不是我所要求的。我将单独评估它。

NOTE: "Use GHUnit" is not an acceptable answer to this question. I know most think GHUnit is better than the Xcode4 OCUnit, but that's not what I'm asking about. I'll evaluate that separately.

我有一个Xcode项目,我是从头开始在Xcode4中创建的,在创建过程中选中了Include unit tests复选框。我还包括了我在之前项目中开发的一些库。它们通过Add Files to x ...对话框添加到项目中,并且仅添加到应用程序目标(而不是测试目标)。它们在运行应用程序时工作正常,所以我认为它们设置正确。我还为这个项目编写了许多不同的类。

I have an Xcode project that I created in Xcode4 from scratch, with the "Include unit tests" checkbox checked during creation. I have also included some libraries I developed in a previous project. They were added to the project via the "Add Files to x..." dialog and only added to the application target (not the testing target). They work fine when running the application, so I think they're set up correctly. I also have a number of various classes written for this project.

我的测试文件是以标准方式设置的,名为[AppName] Tests.h和.m。

标题代码:

#import< SenTestingKit / SenTestingKit.h>

My testing files are set up in the standard way, named [AppName]Tests.h and .m.
Code for header:
#import < SenTestingKit/SenTestingKit.h >

@interface [AppName]Tests : SenTestCase {
@private
}
@end

实施准则:

#import[AppName] Tests.h

@implementation [AppName]Tests

- (void)setUp
{
    [super setUp];
    // Set-up code here.
}

- (void)tearDown
{
    // Tear-down code here.
    [super tearDown];
}  
// Test methods go here
@end

这只是基本的骨架。它在我的其他项目中工作正常,并且在这个项目中,只要我不导入任何其他文件。当我从该项目导入另一个文件并使用它时,我在Xcode输出日志中看到以下错误:

/ Users / [Me] / Library /中的测试包Developer / Xcode / DerivedData / [AppName] -dwuuuwcpmdqxqmgxomoniplwhlpb / Build / Products / Debug-iphonesimulator / [AppName]由于发生链接错误,无法加载Tests.octest。 dyld可能找不到测试包链接的框架框架或库,可能是因为框架或库在链接时的安装路径不正确。

Which is just the basic skeleton. It works fine in my other project, and in this project as long as I don't import any other files. When I do import another file from this project and use it, I see the following error in the Xcode output log:
The test bundle at /Users/[Me]/Library/Developer/Xcode/DerivedData/[AppName]-dwuuuwcpmdqxqmgxomoniplwhlpb/Build/Products/Debug-iphonesimulator/[AppName]Tests.octest could not be loaded because a link error occurred. It is likely that dyld cannot locate a framework framework or library that the the test bundle was linked against, possibly because the framework or library had an incorrect install path at link time.

我已经验证过:


  1. 我使用的所有框架都添加了
    应用程序和测试
    目标的链接二进制文件与
    库。

  2. 测试目标已配置
    以正确构建并且我的所有
    测试方法显示在编辑
    方案...->测试 - >测试

  3. 每个问题但是这个已经解决了
    并且有没有编译器
    错误。

  4. 所讨论的所有设置
    这里
    设置正确且与我正确测试
    的其他项目相同

  1. All the frameworks I use have been added to "Link Binary with Libraries" for both the app and test targets.
  2. The test target has been configured to build correctly and that all my test methods show up in Edit Scheme...->Test->Tests
  3. Every issue but this one has been resolved and there are no compiler errors.
  4. All the settings discussed here are set up correctly and identical to my other project that tests correctly.

关于可能导致此问题的任何想法?

Any thoughts on what might be causing this?

推荐答案

我必须将单元测试目标上的测试主机属性设置为 $(BUNDLE_LOADER )。这解决了我的问题!

I had to set the "Test Host" property on the unit test target to $(BUNDLE_LOADER). That solved my problem!

这篇关于Xcode 4单元测试链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆