为 iOS 构建 OCUnit 应用程序测试目标时出现链接器错误
我的 OCUnit 目标中包含一个应用程序测试。我可以调用应用程序主机目标中的类的实例方法,但无法调用类方法。如果我调用一个类方法(如 alloc
),我会收到以下链接器错误:
Undefined symbols for architecture armv6:
"_OBJC_CLASS_$_DiceGameViewController", referenced from:
objc-class-ref in DiceGameViewControllerTest.o
(maybe you meant: _OBJC_CLASS_$_DiceGameViewControllerTest)
ld: symbol(s) not found for architecture armv6
collect2: ld returned 1 exit status
我认为这是因为 Objective-C 在链接时不需要访问对象文件来进行实例调用,但确实需要在链接时进行类调用的访问。有人可以指出我的文档来确认这一点吗?
此问题类似于以下问题:
I have an Application Test included in my OCUnit target. I can call instance methods on classes in my Application Host target, but I cannot call class methods. If I call a class method (like alloc
), I get the following linker error:
Undefined symbols for architecture armv6:
"_OBJC_CLASS_$_DiceGameViewController", referenced from:
objc-class-ref in DiceGameViewControllerTest.o
(maybe you meant: _OBJC_CLASS_$_DiceGameViewControllerTest)
ld: symbol(s) not found for architecture armv6
collect2: ld returned 1 exit status
I assume this is because Objective-C doesn't need access to the object file at link time to make instance calls, but does need access at link time for class calls. Can someone point me to documentation to confirm this?
This question is similar to these questions:
请参阅我的答案 使用 XCode 4 进行单元测试的链接错误?
See my answer in Linking error for unit testing with XCode 4?