建立单元测试目标时出现链接错误 [英] Link error while building a unit test target

查看:82
本文介绍了建立单元测试目标时出现链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有常规目标和单元测试目标的XCode4/iOS项目.一切正常,除非我尝试在测试类中#import我的一个类并尝试使用它.如果我尝试构建单元测试目标,则会收到以下链接错误:

I have a XCode4 / iOS project with a regular target and unit test target. Everything works fine, except when I try to #import one of my classes in my test class and try to use it. If I try to build the unit test target, I get the following link error:

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_FRRCategory", referenced from:
      objc-class-ref in CategoryTests.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

在CategoryTests.m中,我以这种方式导入头文件:

In CategoryTests.m I'm importing the header file in this way:

#import "../todoro/FRRCategory.h"

我在做什么错了?

推荐答案

确保已将FRRCategory源文件添加到单元测试目标的编译源"中.

Make sure that the FRRCategory source file has been added to your Compile Sources for your unit test target.

Xcode 4:

Project Navigator->"[Project Name]"->在Targets下,选择您的单元测试目标-> Build Phases-> Expand Compile Sources->单击Compile source底部的+,然后添加正确的源文件.

Project Navigator -> "[Project Name]" -> Under Targets select your unit test target -> Build Phases -> Expand Compile Sources -> Click + at bottom of Compile sources and add the correct source file.

这篇关于建立单元测试目标时出现链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆