我在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&#34; SignIn.h&#34;和@property(非原子)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)
我已经在这方面工作了很长时间,真的需要有人帮忙。谢谢!
答案 0 :(得分:1)
当尝试将单元测试添加到现有iOS项目时,有时需要设置&#34;默认隐藏的符号&#34;在主应用目标的构建设置中为否。 查看此帖子:http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
它仍适用于xcode 7.感谢托德!