Sharing code between projects/targets?


Hi -

I’m developing an app for the iPhone and IPad. I plan to sell them separately, so it’s not a Universal app.

Needless to say there will be lots of code reuse, so I’m curious how others recommend structuring the project or projects to accomplish two products and allow for code reuse.





I do something like this all the time. I’d recommend having two targets in the same project. Each target will have it’s own build product.

Files that are part of both versions of the app should be included with both targets:

  1. While editing the *.m file
  2. Open the Utilities pane (menu on the right side of Xcode)
  3. Select the first tab (File inspector)
  4. Edit the “Target Membership” section

Files that are specific to one version of the app should only be included in the respective target.

You’ll also have a build scheme for each target that should be automatically created.

Alex Silverman
Lead Software Engineer & Instructor
Big Nerd Ranch, Inc.


Hi Alex,

Thanks for the reply. interesting approach

Since my first post I’ve got things working with a Workspace including a static lib project, an iPhone project and a iPad project.

Is there a downside to this approach?




Nope! That’s a fine approach too. In fact, I’d take your route if you foresee even more versions of the app. For a “template factory” you can put all the common things in a static library, and then just create a new project for each customization.


Awesome… thanks.

The apps will share a common data model so from what I’ve read this will provide some ‘opportunities’ in regards to bundles and getting datamodel from static library.

btw - love the IOS book. It’s a great help!