Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: project settings vs. target settings

I'm creating a static lib on Mac OS X for one of our customers, as well as a small cmd line app to test the static lib. The cmd line project has 2 extra library search paths, which meant I was linking to the Debug version in Release mode and just about went crazy, so I tried to get rid of these two paths, but I couldn't find where they were specified. I was looking in the project info, but it turns out they were specified in the target info.

I don't understand the distinction?! Why there are 2 sets of settings, which are essentially the same?! Can someone please enlighten me?

like image 674
vectorizor Avatar asked Oct 29 '09 10:10

vectorizor


People also ask

What is the difference between project and target in Xcode?

A target defines a single product; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. Projects can contain one or more targets, each of which produces one product.

What is Target membership Xcode?

Making an implementation file a member of a target tells Xcode to compile the file when you build the target. In your example Xcode compiles the file myAppFile. m when you build the myAppTests target but not when you build the myApp target.

How do I change project target in Xcode?

Changing the target name is just as simple. Click on the project name at the top left, then select a target name on the right pane followed by pressing "Enter". Type in the new name. @Alan, in Xcode 6, this was changed to a square icon, with a bolded line on the left side.

Where is target settings in Xcode?

Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.


2 Answers

A project can contain multiple targets. For example, an app I write has four - the app itself, a Quick Look plugin, a framework and a bundle that contains Mac OS 10.6-specific functionality that can be dynamically loaded in.

Project settings apply to every single target in the project. Each target can then override individual settings if they need to - for instance, my project's Target SDK is set to 10.5, but the 10.6-specific bundle has it's Target SDK set to 10.6.

In some instances, some settings don't make sense to be in Project Settings - one of these, I guess, is search paths.

like image 146
iKenndac Avatar answered Oct 23 '22 01:10

iKenndac


You often have multiple targets in a single project - for instance, you might have a framework project with a target for building as a dynamic .framework bundle, and a target for building a static lib. Or your app might have a target for building the app itself, and a target for building some helper command-line tool that it needs to install.

Wherever possible, I'd suggest changing settings at the highest level (in the project settings, and simultaneously changing debug & release configurations), and only customizing the target settings when necessary. Even better, move as many settings as possible into xcconfig files, which seem a much more explicit way of specifying your build setup.

like image 38
Jonathan del Strother Avatar answered Oct 23 '22 01:10

Jonathan del Strother