铿锵声:错误:链接器命令失败,退出代码1(使用-v看到调用)时,在xcode上进行unit testing
当我在xcode上进行unit testing时遇到这个错误。 我尝试导入“SignIn.h”并testingSignIn.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]; } ...
我只是按照通常的unit testingstream程。 导入“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)
我一直在这个工作很长一段时间,真的需要有人来帮忙。 谢谢!
当试图将unit testing添加到现有的iOS项目中时,有时需要在主应用程序的构build设置中将“默认隐藏符号”设置为否。请检查此帖: http : //twobitlabs.com/2011/06 /添加-的OCUnit到一个存在的-IOS-项目与- xcode中-4 /
它仍然适用于xcode 7.谢谢托德!