How to utilize Xcode project & target to manage products

iosproject-managementversion controlxcode

At first, hopefully following terms project and product won't be confused.

Traditionally, we used to have a code base, which usually was a main project. For our products, we created one project for each product, and these projects surly depended on main project (code base). When product was released, we created release branch for archive and maintenance.

Now I'm developing iOS applications, and I noticed there were specific terms for Xcode, project and target, which were similar to project and product. At first look, it's more easier to share configuration between products, to simplify product releases by taking advantage of target and target dependencies. Compared with traditional way, on the other hand, it's more difficult to manage source code, to branch, etc, if number of products goes really large.

In practice, is anyone efficiently using this Xcode built-in structure to manage code and products?
I'm quite new at iOS & Xcode and looking for good advice, thanks.

Best Answer

It sounds like you're talking about using Xcode to build a Software Product Line kind of a configuration. I've done something like this before with respect to white-labelling a product - so there were no code changes between products, just different resources.

My approach would be to define a different target for each product - whether they're in the same project or not is up to you. Xcode handles dependencies across different projects quite well, so you could easily define multiple projects that state their dependencies, and use xcconfig files[*] to maintain configuration details that must be the same across all targets. It's easiest to do that from a version control perspective, to reduce the chance that people working on different products will need to edit the same project file.

Put the code that goes into all products into its own (static library) target, and include that target as a dependency of the other targets. Similarly if there are resources that are shared across all projects, create a "bundle" target that includes those shared resources.

[*] An xcconfig file is a plain text file containing Xcode build settings. If more than one of your projects contains targets that should use the same build settings, you can base those targets all on the same .xcconfig file so the settings are defined in the same place.

Related Topic