Skip to content

Commit

Permalink
chore(): add a hook to make builds work nicely with xcode8+
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Apr 10, 2017
1 parent ead5982 commit 49c39fd
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hooks/before_compile/xcode8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node

"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);
}
};

0 comments on commit 49c39fd

Please sign in to comment.