Jacob
Jacob

Reputation: 1896

Best way to share code between multiple projects in iOS

We're planning to launch a serie of applications in AppStore. They will be for some kind of different journals, showing different contents downloaded from a server via XML. So these applications will be made from exactly the same code (It's an universal application, so It'll work both in iPhone/iPad).

My initial idea was, in order to upload the application, compile just changing the images, logos and configurations (plist) that makes the application react as a particular journal. The compressed file would be uploaded to the AppStore.

However, this has resulted a horrible method, which promotes failures and mistakes. If I forget to change some image, as you can't see them in the compiled file (as it is included) they will end up in the store (and I will need four or five days in order to get the application changed).

I'm trying to look up for a better approach, wich keep the projects as independent as possible. I would like to be able to share the entire codebase: views, classes and nibs and create different projects for every journal.

Which is the best method to achieve that?. What structure would let me group both logic (controllers, classes) and UI and use it in the different projects?.

I hope I've explained.

As always, thank you very much.

Upvotes: 7

Views: 5800

Answers (4)

hotpaw2
hotpaw2

Reputation: 70743

An Xcode project can have multiple Targets, all the Targets sharing code, but each Target getting its own resources (icons, images, text, plists, etc.) from a different subdirectory/folder within the same project directory/folder. Then you can check the whole thing, or just the shared source, into your source control repository.

You should also be testing each of your apps, built exactly the same way as any submission except for the codesigning, on a device before uploading to the store.

Upvotes: 4

rob mayoff
rob mayoff

Reputation: 386018

You can have a single Xcode project that creates multiple applications. You'll need to create a separate Info.plist with a different bundle identifier for each app.

Upvotes: 0

Aditya Kumar Pandey
Aditya Kumar Pandey

Reputation: 991

You should keep most of your common code as a library project. Each final project should link with this project and provide images/assets along with code to mention these assets to common code. In my day job, I write a common library too, which gets used by 2 products/apps at my employer.

Upvotes: 7

utahwithak
utahwithak

Reputation: 6335

If you are using a git repository you can just branch for each different app you want and that would keep track of all the differences and if you need to switch which you are working on you just have to checkout that branch. This would allow for the exact same structure just minor differences between the actual code for each.

Upvotes: -3

Related Questions