Take the 2-minute tour ×

I'm trying to add my parser.m file to the target of my unit test (or, of my unit test file?), but I have no idea how.

Here's an example of a page that indicates the necessity of using the target:

Undefined symbols for architecture i386 "_OBJC_CLASS_$_Appirater"

...and here's part of an answer from that page:

I think, that you only added files to project, but not to target. Click on Appirater.m file in Project Navigator and set checkbox near to your target name in Target membership of File Inspector.

What I don't get from that answer is, "what checkbox?". Also, how do I know my target name? Where do I find 'Target membership'?

share|improve this question
You should go read the documentation –  toasted_flakes Jan 3 '13 at 21:50
@grasGendarme: Thank you for that link. I had already been there, and was missing the crucial piece of information of how to get to the Target Membership section (or even that there was such a section). However, someone else may find that link answers their question. –  annag Jan 3 '13 at 22:20
add comment

1 Answer

up vote 32 down vote accepted

In Xcode, a target is usually an app - the app which you are creating! Occasionally it is a library or framework. (You can create other kinds of targets but don't worry about that.)

You can use the File Inspector to add a file to a target, or remove a file from a target, or just check whether a file is a member of a target. Simply open a .m file or a resource file (like an image or xib) in the editor pane, then select the File Inspector in the right-hand pane of the Xcode window and find the “Target Membership” section of the inspector. Check or uncheck the box next to your target. (You usually do not want to add .h files to targets.) Here's a demonstration:

add MyObject.m to addToTargetDemo target

If you have multiple targets in the project, each target appears in the “Target Membership” section. Each source file can be a member of any combination of the targets, depending on your needs. For example, if you are creating separate iPhone and iPad apps (instead of a universal app) which share most of their code and resources, you can create a project with two targets. One target is the iPhone app and the other target is the iPad app. You add the common source files to both targets. You add the iPhone-specific .m files and resource files to the iPhone app target only. You add the iPad-specific .m files and resource files to the iPad app target only.

share|improve this answer
Thank you so much! This was incredibly helpful. –  annag Jan 3 '13 at 22:15
@rob, what app did you use to record that mini-screencast-gif? –  epologee Oct 16 '13 at 9:08
A combination of ScreenFlow and Photoshop. –  rob mayoff Oct 16 '13 at 14:35
+1 for the animated gif.. :O –  Frade Oct 22 '13 at 14:25
add comment

Your Answer


