Skip to content

Instantly share code, notes, and snippets.

@mbijon
Forked from dpogue/xcode8.js
Created April 17, 2017 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbijon/1568021d9f50c7d186d4c866f27dd84d to your computer and use it in GitHub Desktop.
Save mbijon/1568021d9f50c7d186d4c866f27dd84d to your computer and use it in GitHub Desktop.
Hook for Cordova iOS to support "developmentTeam" in buildConfig.json
"use strict";
var fs = require('fs');
var path = require('path');
module.exports = function(context) {
var encoding = 'utf-8';
var filepath = 'platforms/ios/cordova/build.xcconfig';
if (context.opts.cordova.platforms.indexOf('ios') === -1) return;
if (!context.opts.options) return;
if (!context.opts.options.buildConfig) return;
var buildType = context.opts.options.release ? 'release' : 'debug';
var buildConfigPath = context.opts.options.buildConfig;
if (!path.isAbsolute(buildConfigPath)) {
buildConfigPath = path.join(context.opts.projectRoot, context.opts.options.buildConfig);
}
var config = require(buildConfigPath);
if (!config.ios) return;
if (!config.ios[buildType]) return;
if (!config.ios[buildType].developmentTeam) return;
var xcconfig = fs.readFileSync(filepath, encoding);
if (xcconfig.indexOf('DEVELOPMENT_TEAM') === -1) {
var content = '\nDEVELOPMENT_TEAM = ' + config.ios[buildType].developmentTeam;
xcconfig += content;
fs.writeFileSync(filepath, xcconfig, encoding);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment