cordova-plugin-enable-bitcode
Version:
Enable bitcode in iOS build settings
36 lines (28 loc) • 1.12 kB
JavaScript
/*
* Enable bitcode for iOS projects.
*/
var fs = require('fs');
var xcode = require('xcode');
var path = require('path');
var semver = require('semver');
module.exports = function(context) {
var projectName, projectPath, xcodeProj;
var projectRoot = context.opts.projectRoot;
projectName = getConfigParser(context, path.join(projectRoot, 'config.xml')).name();
pbxPath = path.join(projectRoot, 'platforms', 'ios', projectName + '.xcodeproj/project.pbxproj');
xcodeProj = xcode.project(pbxPath);
//We need to use parseSync because async causes problems when other plugins
//are handling pbxproj file.
xcodeProj.parseSync();
xcodeProj.updateBuildProperty('ENABLE_BITCODE', 'YES');
fs.writeFileSync(pbxPath, xcodeProj.writeSync());
};
function getConfigParser(context, config){
if(semver.lt(context.opts.cordova.version, '5.4.0')) {
ConfigParser = context.requireCordovaModule('cordova-lib/src/ConfigParser/ConfigParser');
} else {
ConfigParser = context.requireCordovaModule('cordova-common/src/ConfigParser/ConfigParser');
}
return new ConfigParser(config);
}