Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link error while building a unit test target

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 

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

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

What am I doing wrong?

like image 322
cfischer Avatar asked Apr 25 '11 21:04

cfischer


People also ask

What are the errors commonly found during unit testing?

Unit testing considerations What errors are commonly found during Unit Testing? (1) Misunderstood or incorrect arithmetic precedence, (2) Mixed mode operations, (3) Incorrect initialization, (4) Precision inaccuracy, (5) Incorrect symbolic representation of an expression.

What is unit testing explain the various targets for unit testing?

In computer programming, unit testing is a software testing method by which individual units of source code—sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures—are tested to determine whether they are fit for use.

Does typescript replace unit tests?

This can definitely replace some of your logic tests.


2 Answers

Follow the instructions here. It doesn't require you to add any files to compile sources.

I first missed that "Symbols Hidden by Default=NO" should be for your app target, not test target.

It worked for me anyway (tm).

like image 124
Martin Wickman Avatar answered Sep 29 '22 02:09

Martin Wickman


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]" -> Under Targets select your unit test target -> Build Phases -> Expand Compile Sources -> Click + at bottom of Compile sources and add the correct source file.

like image 39
Joe Avatar answered Sep 29 '22 02:09

Joe