0

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.

1 Answer 1

2

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\"
1
  • This sounds like exactly what I need. I'm a bit foreign with how Phonegap and XCode operate together so I'll try to go through these steps to get what I want. Thank You! Aug 10, 2013 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.