The difference between adding to the target and adding to the project in Xcode

I am trying to cancel the Google Toolbox for mac for unit testing purposes on this page http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting says add file blahblah.m target and add file blahblah. m into your project.

What is the difference, how can I add to the target ...

+4
source share
2 answers

In order to "Add to Project", you just need to drag and drop the file into the Xcodes sidebar. In the end, it should look like this:

Xcode sidebar screenshot

Add to Target means the file must be in the Source Compilation group of your LogicTests target.

Xcode target screenshot

You can also check if the file has been added to the currently active target by looking at the right flag in the Details panel:

Xcode detail panel

+6
source

Make "Get Information" in the file by dragging it to your project. You will see checkboxes for each target. Just check the box or make sure it is set to make sure it is added to your target.

Adding something to a project usually, depending on the type of file, automatically adds it to all the goals that make sense.

Adding a file to the target tells the build system that the target depends on the file and that the file must be somehow included in the target assembly. In the case of resources, they are simply copied to the application package. In the case of .m files, they are compiled and linked.

I am not familiar with the Google Toolbox, but most likely, for unit testing, you want your unit test.m files to be added to your unit test target, and not to your real target program so that they do not compile into your application.

+4
source

All Articles