views:

37

answers:

1

I have two apps which share a lot of source, so I want to put them into one Xcode project and use Targets to build them seperately. Some of the source files have the same name in both projects (for example, MapViewController.h and MapViewController.m). I thought as an intermediate step, I'd just put the whole classes folder into the merged project (with a different folder name) and use Targets to specify which classes folder to use, then later I'd properly merge what I could into common source files.

The problem I found is that I can't include .h files in a Target (the option is greyed out). Do I need to use the same interface file for both Targets and have two versions of the implementation files. Is there a better way to do this? Thanks.

+1  A: 

If your going to have two apps with similar naming conventions, with shared code... I'd recommend using the following approach.

Create 3 Xcode projects.

  • Project 1: Core Code (shared code, resources)
  • Project 2: App 1 (import Project 1 and create a dependency on it)
  • Project 3: App 2 (import Project 1 and create a dependency on it)

Now, every time you change Project 1, both your other projects will be affected.

I've created a project the way you want to right now... And in the long run i've greatly regretted it.

Brad Goss
Why have you regretted the all-in-one-project approach?
Nick Dowell
Brad Goss
Thanks for the answer Brad. I've decided to go along with several targets in one project. I want to understand what makes it difficult to do myself. Probably I'll come back to your answer and implement it this way after I understand more.
nevan
Brad Goss