Search code examples
xcodetargets

How do I run a preferred target in Xcode?


I'm studying a simple application demo from Apple that has two (2) targets.
Each target has its own plist, storyboard and some code; with a few files shared between them.

Choosing the 'R'un, runs one default target. I want to specify what target to run.

How do I select the target to run in Xcode?

enter image description here


Solution

  • If you have more than one app target, you have more than one scheme. If you have more than one scheme, you can pick a scheme from the scheme menu (at the top of the project window). Then when you run, that scheme will be what builds and runs (on the corresponding destination).

    In this screen shot, I have two app targets and hence two schemes ("backgroundPlayer" and "interrupter"):

    enter image description here

    As you can see, "backgroundPlayer" is checked. So if I build and run now, I build and run "backgroundPlayer". But if I choose "interrupter", then it will be checked, so if I then build and run, I build and run "interrupter".