gpt4 book ai didi

ios - Xcode 4 单元测试链接器错误

转载 作者:IT王子 更新时间:2023-10-29 08:10:54 26 4
gpt4 key购买 nike

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

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

我的测试文件以标准方式设置,命名为 [AppName]Tests.h 和 .m.
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 输出日志中看到以下错误:
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. 讨论的所有设置 here设置正确且相同到我的其他测试项目正确。

对可能导致此问题的原因有任何想法吗?

最佳答案

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

关于ios - Xcode 4 单元测试链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6268259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com