View Full Version : Can one Xcode project create multiple products?
Nov 22, 2008, 11:01 AM
I have created an app, let's call it A, and now I want to create a new app, let's call it B, where B is a superset of A -- that is, B has everything in A plus some more. But I still want to maintain A as well. I could simply make a copy of A and then start adding the 'B' functionality, but then I would have to make fixes to 'A' functionality in both places. Can I configure my Xcode project to have two different targets, A and B, where:
- A and B have different main nibs
- A and B have different plist.info files
- A and B have different names
any tips from those who have done this would be appreciated
Nov 22, 2008, 04:47 PM
It sounds like your problem's solution will be far simpler than what I'm about to describe (perhaps you're making a Lite and regular version of an app?), but this is how I handled shared code between my apps.
I chose GIT as my version control system because of its support for Submodules. Submodules allow you to share code between multiple repositories so that an update to the submodule in one project will update that code in every other project that uses that submodule (each repository must "opt-in" for each update). In your case, each app could be its own repository and the code shared between the apps could be a submodule so each app can always have the latest shared code. Or A could be a repository and a submodule for B.
Nov 22, 2008, 09:34 PM
Each target in a project builds a different binary. Each file in a project can be in one or more targets. If you're developing two apps that share a lot of code you can make them two targets in one project.
You should read the Xcode project management guide for the details.
Nov 23, 2008, 12:22 AM
It's easy to create 2 different targets in XCode, with 2 different product names, and 2 completely different sets (or partially overlapping sets) of source code and nib files. Use the little checkboxes in the XCode project group file browser to select and deselect different class and nib files for each project. Then edit the target settings for product names, & etc. You can also add target specific defines and use #ifdef's in your source code.
The problem seems to be with the Default.png, Icon.png, and Info.plist files. Renaming the icon file seems possible, but there may be reports that apps with renamed app icons have problems with uploading to the app store. Maybe a build script can be added to symlink or copy these 3 files into the project directory from a set of sub-directories before each build?
Nov 24, 2008, 08:56 PM
If you have multiple files with the same name that you want to add to your project just put them in different folders. You can add them to your project and set the target for them so one goes to one binary and the other goes to another.
Nov 28, 2008, 07:54 PM
The problem seems to be with the Default.png, Icon.png, and Info.plist files.
I ended up adding a second target to my project, and that seems to have been pretty straightforward. When I added the second target, it also automatically added a new info.plist file for this target (named target-info.plist) and in that new plist I can specify a different main xib, a different icon, etc...