2

I made a generic app, and from that app, I use different images to make different apps (same app, different images).

My idea until now has been every time I was generating a new app, I copied the code and changed the images (and sometimes some lines of code). But every time I change something in the main app, I have to change it in all the sub-apps.

I've been thinking about using target for this (every time I create a new one, I use a new target with a new folder images linked to it), but I'm not sure about this as I never worked with targets before.

Is this the best approach?

And if it is, how is the best way of doing it? I created a new target inside my project, but it creates a whole new project inside of it, with its owns classes.

justin
  • 104,054
  • 14
  • 179
  • 226
Antonio MG
  • 20,382
  • 3
  • 43
  • 62

2 Answers2

8

For your case, using multiple targets is a good solution. For each target you'll include all sources, and only the images used by that target (images can have the same name, just put them in separate folders).

On Xcode 4, you'd need to follow these steps:

  1. Go to Project settings, right click on your main app target and choose 'Duplicate'. This will already include same sources from the main app.

  2. Unlink all images that you don't need in your new target:

    • select all images that you want to unlink, and in the utilities panel (usually placed on the right), in the 'File Inspector' section, uncheck your new target
  3. Create a new folder in which you place the images for your new target/app, and when you import them in the project, choose to link only with your new target.

  4. When you duplicate your target, it will also automatically create a new info.plist for your new app. You'll need to change the bundle id, and any other options that you wish.

Another option would be to make the main project as a static library, and in all other projects include the main project, and link the target. Won't get into this, since the targets solution seems better for your case, for only changing the images.

alex-i
  • 5,406
  • 2
  • 36
  • 56
0

I wish to add a link showing howto - in support of the above answer. Hope it will be helpful to others also.

iOS Mobile Development: Using Xcode Targets to Reuse the Code

http://www.itexico.com/blog/bid/99497/iOS-Mobile-Development-Using-Xcode-Targets-to-Reuse-the-Code

SHS
  • 1,414
  • 4
  • 26
  • 43