You can use the after_prepare binding, which will apply the settings after cordova prepare and therefore avoid overwriting them on each cordova build . Put the following code in <your_project>/hooks/after_prepare/some_file.js :
#!/usr/bin/env node // Set support for all orienations in iOS .plist - workaround for this cordova bug: https://issues.apache.org/jira/browse/CB-8953 var platforms = process.env.CORDOVA_PLATFORMS.split(','); platforms.forEach(function(p) { if (p == "ios") { var fs = require('fs'), plist = require('plist'), xmlParser = new require('xml2js').Parser(), plistPath = '', configPath = 'config.xml'; // Construct plist path. if (fs.existsSync(configPath)) { var configContent = fs.readFileSync(configPath); // Callback is synchronous. xmlParser.parseString(configContent, function (err, result) { var name = result.widget.name; plistPath = 'platforms/ios/' + name + '/' + name + '-Info.plist'; }); } // Change plist and write. if (fs.existsSync(plistPath)) { var pl = plist.parseFileSync(plistPath); configure(pl); fs.writeFileSync(plistPath, plist.build(pl).toString()); } process.exit(); } }); function configure(plist) { var iPhoneOrientations = [ 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight', 'UIInterfaceOrientationPortrait' ]; var iPadOrientations = [ 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight', 'UIInterfaceOrientationPortrait' ]; plist["UISupportedInterfaceOrientations"] = iPhoneOrientations; plist["UISupportedInterfaceOrientations~ipad"] = iPadOrientations; }
Note: you need to install plist and xml2js node if you do not already have them.
source share