2

There is a similar question at Best practice for managing project variants in Git? but the context is different and I suspect the answer might be too.

I have a Cocoa product "First" managed with Xcode and versioned using git. "First" is still evolving, and is currently at its third version.

Then a customer comes and ask for a variant of First, called Second. The changes from First to Second affect many, but not all, files. The changes affect source code but also resources (graphics elements, nib files, property lists...).

Now the two products are alive and share a number of common files. However, some changes such as bug fixes might apply to both products. Possibly, a new feature might be added to both products.

What would be the best way to manage such a scenario:

  • with Xcode
  • with git

I have two ideas, which are mutually exclusive:

Idea 1: git branch "First" into "Second", and apply any applicable change from one project back to the other one. This leads to two totally separate Xcode directories and projects.

Idea 2: Add a target named "Second" to the Xcode project. Now the same Xcode project has two targets and is used to develop and build both products. But this makes it difficult to manage releases for First and Second in git (releases have no reason to be synchronized).

Idea 2 makes the parallel development process very easy. Code is always in sync. Divergences can be handled through compile-time variables and a single source file OR through different source files. It makes version management more obscure though.

Idea 1 is perhaps cleaner, but then, what's the best practice to manage whatever stays common between the two projects? Can you do a "partial merge" between two git branches? On what basis? Or must that be handled manually?

It might be possible to encapsulate and extract some common part into a module or library, but not always. For example I don't think that's possible for the common document icons. Also refactoring "First" so that all common items are extracted away in a build-able manner is a major undertaking that I'd rather do a bit at a time.

I realize there may not be a perfect solution. I am looking for ideas and suggestion. As a relatively recent git adopter I also realize that this may be an RTFM question. Then simply point me to the FM to R.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Jean-Denis Muys
  • 6,772
  • 7
  • 45
  • 71

1 Answers1

0

My preference is idea2. I currently do this as a way of writing a plug-in for the Main App, and then client apps that go on all the nodes of a cluster. The Plug-in and clients share 90% of the same code, so this makes it super-easy to maintain and debug the where/how of what's going on.

Stephen Furlani
  • 6,794
  • 4
  • 31
  • 60