How to use Targets in Xcode

Targets are an extremely yet totally undocumented feature of Xcode. They allow you to write code once, and then build multiple “versions” of the same code base. This makes maintenance and code updates extremely easy across more than “product”.

I use those quotation marks because usually an “Xcode Project” equals a “Product” (such as one iPhone app, or one Mac app). But really it’s the Target that defines the product, and it is feasible to write code once and use it to create several “product versions” of your app, for example: