注意:“使用 GHUnit”不是这个问题的可接受答案。我知道大多数人认为 GHUnit 比 Xcode4 OCUnit 更好,但这不是我要问的。我将单独评估。
我有一个从头开始在 Xcode4 中创建的 Xcode 项目,在创建期间选中了“包括单元测试”复选框。我还包括了一些我在以前的项目中开发的库。它们通过“将文件添加到 x...”对话框添加到项目中,并且仅添加到应用程序目标(而不是测试目标)。它们在运行应用程序时工作正常,所以我认为它们设置正确。我还为这个项目编写了许多不同的类。
我的测试文件以标准方式设置,名为 [AppName]Tests.h 和 .m。
标题代码:
#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.
我已经验证过:
- 我使用的所有框架都已添加到应用程序和测试目标的“Link Binary with Libraries”中。
- 测试目标已配置为正确构建,并且我的所有测试方法都显示在 Edit Scheme...->Test->Tests
- 除此之外的所有问题都已解决,并且没有编译器错误。
- 这里讨论的所有设置 都设置正确,并且与我测试正确的其他项目相同。
关于可能导致这种情况的任何想法?