问题描述
在xcode上进行单元测试时遇到此错误.我尝试导入"SignIn.h"并测试SignIn.h/SignIn.m中定义的VerifyEmail类.
I meet this error when I do a unit test on xcode. I try to import "SignIn.h" and test the VerifyEmail class which is defined in SignIn.h/SignIn.m.
我的代码如下:
#import <XCTest/XCTest.h>
#import "SignIn.h"
@interface SignInTests : XCTestCase
@property (nonatomic) VerifyEmail* verifyEmail;
@end
@implementation SignInTests
- (void)testVerifyEmail
{
_verifyEmail = [[VerifyEmail alloc] init];
}
...
我只是遵循通常的单元测试管道.导入"SignIn.h"和@property(非原子)VerifyEmail * verifyEmail可以,但是当我尝试初始化verifyEmail(_verifyEmail = [[VerifyEmail alloc] init];)时,出现以下错误:
I just follow the usual unit test pipeline. import "SignIn.h" and @property (nonatomic) VerifyEmail* verifyEmail are okay, but when I try to initialize verifyEmail (_verifyEmail = [[VerifyEmail alloc] init];) there is an error as below:
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)
我已经为此工作了很长时间,确实需要有人帮助.谢谢!
I have been working on this for a long time and really need someone to help. Thanks!
推荐答案
在尝试将单元测试添加到现有iOS项目时,有时需要在主应用程序目标的构建设置中将默认隐藏的符号"设置为不.检查此帖子: http: //twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
When trying to add unit test to an existing iOS project, sometimes one need to set "Symbols Hidden by Default" in the build settings in the main app target to No.Check this post: http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
它仍然适用于xcode7.谢谢托德!
It still works for xcode 7. Thanks Todd!
这篇关于clang:错误:在xcode上进行单元测试时,链接器命令失败,退出代码为1(使用-v查看调用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!