Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize iphone app for different clients

Tags:

xcode4

iphone

I have an existing app that needs to be compiled for different clients

Each client requires their own icon and splash screen.
I would also like to be able to conditionally include various features depending whether the particular client requires them or not.

I have tried setting up different targets for each client, but not having much luck so far.
The different resources with the same name, but a different path keep getting mixed up.

Ideally I would like to be able to build an app by duplicating another client that is similar and then just make the minimum number of changes to create the app for the new client.

What is the best way to set this app up?

like image 400
John La Rooy Avatar asked Dec 21 '10 22:12

John La Rooy


People also ask

Can you customize iPhone apps?

Type “Open app” in the search bar and then tap on the “Open App” link. Tap on the word “App” that appears (rather faintly) next to the word “Open.” You'll see a list of your apps; pick the one you want to customize. Now, tap the blue symbol in the upper right corner.

How do I distribute IOS apps privately?

From My Apps, select the app you want to distribute privately. This will show you the app's page on App Store Connect. In the sidebar to the left, click on Pricing and Availability. Navigate to App Distribution Methods and select Private — Available as a custom app on Apple Business Manager or Apple School Manager.


2 Answers

Separate targets for each client should be the way to go. For the features, I would suggest first setting up a macro identifying the client in the target settings (under "Preprocessor Macros" on the build tab), then having a FeatureDefines.h file that looks like this:

#ifdef macroClientA // assume client A wants features 1 and 3
#  define macroFeature1
#  define macroFeature3
#endif

// and similarly for the other clients

Now you can use

#import featureDefines
#ifdef macroFeature1

any place you need to test if feature 1 is desired or not.

For the separate icons, your target settings can specify a different info.plist file for each client, and those files can in turn specify a different filename for the icon.

For the separate splash screens, iOS always requires the splash screen to be named Default.png, but they can go in different subdirectories of your project directory. You can control which one is used for which target by right clicking where Xcode says "Groups & Files", selecting Target Membership, then checking the checkbox for the one you want to use, and making sure the other ones are unchecked.

For resources, I would suggest naming your resource files like this:

resourceName.ext // generic resource to be used if there is no client-specific one
resourceName-clientName.ext // client-specific resource

Next set up a general resource-finder method that looks something like this:

-(NSString *) resourcePathForResourceName: (NSString *) resourceName extension: (NSString *) ext {
  NSString *clientName;
  #ifdef macroClientA
     clientName = @"clientA";
  #endif // and similarly for the other clients
  NSString *clientSpecificName = [NSString stringWithFormat: @"%@-%@.%@", resourceName, clientName, ext];
  NSString *genericName = [NSString stringWithFormat: @"%@.%@"];
  if ([[NSFileManager defaultManager] fileExistsAtPath: clientSpecificName])
     return clientSpecificName;
  else if ([[NSFileManager defaultManager] fileExistsAtPath: genericName])
     return genericName;
  else
    // handle the error
}

Running all your resource file grabs through that method will allow you to add client-specific resources to your project without changing a single line of code.

like image 105
William Jockusch Avatar answered Oct 23 '22 12:10

William Jockusch


I have a similar scenario and how I handle it is as follows:

1) the core code of the app is kept in a "application_name-base" folder

2) different clients are in their "application_name-client_name" folder

3) the project file is in the client folder and includes the references from the base folder without using copy.

4) files that need to be unique to the the client's project are in the client folder. Usually images using the same name. or .h .m files that need to be unique to the individual project. Also allows for you to not include files on a project by project basis.

Keeps code central but allows for different code per client without leading to confusion.

like image 30
dredful Avatar answered Oct 23 '22 13:10

dredful