当我在 xcode 上进行单元测试时遇到此错误。我尝试导入“SignIn.h”并测试 SignIn.h/SignIn.m 中定义的VerifyEmail 类。
我的代码如下:
#import <XCTest/XCTest.h>
#import "SignIn.h"
@interface SignInTests : XCTestCase
@property (nonatomic) VerifyEmail* verifyEmail;
@end
@implementation SignInTests
- (void)testVerifyEmail
{
_verifyEmail = [[VerifyEmail alloc] init];
}
...
我只是遵循通常的单元测试流程。 import "SignIn.h"和 @property (nonatomic) VerifyEmail* verifyEmail 没问题,但是当我尝试初始化 verifyEmail (_verifyEmail = [[VerifyEmail alloc] init];) 时出现如下错误:
ld: warning: directory not found for option '-Llibs/Debug-iphonesimulator'
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_VerifyEmail", referenced from:
objc-class-ref in SignInTests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我已经为此工作了很长时间,确实需要有人帮助。谢谢!
最佳答案
当尝试向现有 iOS 项目添加单元测试时,有时需要在主应用程序目标的build设置中将“默认隐藏的符号”设置为否。 查看此帖子:http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
它仍然适用于 xcode 7。谢谢 Todd!
关于ios - clang : error: linker command failed with exit code 1 (use -v to see invocation) when doing unit test on xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32079764/