I am creating a generic app which will have different builds for different customers. The app is 99.5% identical for each customer, the difference being each is branded with the customer’s own particular images and text and app icon etc.
Obviously this could be done using flags such as:
#if defined (CUSTOMER_A)
NSString* text = @"Text for customer A";
UIImage *image = [UIImage imageNamed:@"customerAImage"];
#elseif defined (CUSTOMER_B)
NSString* text = @"Text for customer B";
UIImage *image = [UIImage imageNamed:@"customerBImage"];
But obviously I’d like to avoid this and just have:
NSString* text = @"Text";
UIImage *image = [UIImage imageNamed:@"image"];
(The text would be localizable, so it would be using NSLocalizedString in the final version).
I was wondering if a possible approach would be to place the project into a workspace along with a number of static libraries, each of which contains the specific text and images for each customer and then use different schemes to create different builds. So Scheme A would create a target built with the main project and static library A for example.
I started with a small proof of concept but before going too far with it I’d first like to check this is a feasible and reasonable approach, or if there’s a better alternative. If it is feasible then a few questions come to mind:
-
how can an image in a static library be accessed from the code in the main project? Does a bundle have to be created to access the contents of the library, how is this done?
-
is it possible to change the application desktop and marketplace icons depending upon which scheme is used?
-
is it possible to specify a different set of distribution certificates etc. to be used per scheme?
-
is it true that static libraries cannot contain localized variants?
This is for iOS so its not possible to use a framework for this.
Thanks for any feedback.
(P.S. the build system will be automated using Jenkins).
You just need to create multiple targets in your project and have
resource folders for each target (customer/brand).
Here’s how to accomplish this:
a. Resources_Customer1
b. Resource_Customer2
customer/brand
Hope this helps!