Playforward
Playforward

Reputation: 560

How to use different config.xml for different Phonegap Targets in Xcode?

I want to have multiple targets in my Phonegap Xcode project that share resources but load from a different index.html file.

The index file that is loaded is determined by the config.xml file.

How can I define a different config.xml file or a different index.html file for these different targets.

Alternatively, is there a better way to apply settings, and deploy an app that is 99.9% the same?

I'm using Cordova 2.8.1.

Thank you.

Upvotes: 0

Views: 1276

Answers (1)

Chuck
Chuck

Reputation: 36

PhoneGap's CDVViewController.m reads config.xml from the main bundle, so you can

  1. Create a separate directory for each target.
  2. Create a config.xml for each target in the associated directory from step 1.
  3. Use the Target Membership panel in Xcode's Utilities view to set the target membership of each config.xml from step 2 to the correct target.

If the only difference is the starting HTML file, you could modify your AppDelegate.m and use a compile-time constant to define the starting page:

self.viewController.startPage = [NSString stringWithFormat:@"%s", START_HTML_FILE];

To set the compile time constant, go into Build Phases tab in Xcode for each target and use the -D compiler flag. For example:

-DSTART_HTML_FILE=\"target1-index.html\"

Upvotes: 2

Related Questions