Skip to content

Commit

Permalink
Update build.js to set Xcodeproj properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Jan 11, 2019
1 parent c584a0f commit 6e65f22
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions bin/templates/scripts/cordova/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,39 @@ module.exports.run = function (buildOpts) {
return findXCodeProjectIn(projectPath);
}).then(function (name) {
projectName = name;
var extraConfig = '';

var locations = {
root: projectPath,
pbxproj: path.join(projectPath, projectName + '.xcodeproj', 'project.pbxproj')
};

var project = projectFile.parse(locations);

if (buildOpts.codeSignIdentity) {
extraConfig += 'CODE_SIGN_IDENTITY = ' + buildOpts.codeSignIdentity + '\n';
extraConfig += 'CODE_SIGN_IDENTITY[sdk=iphoneos*] = ' + buildOpts.codeSignIdentity + '\n';
events.emit('verbose', 'Set CODE_SIGN_IDENTITY to ' + buildOpts.codeSignIdentity + '.');
project.xcode.updateBuildProperty('CODE_SIGN_IDENTITY', `"${buildOpts.codeSignIdentity}"`);
}

if (buildOpts.codeSignResourceRules) {
extraConfig += 'CODE_SIGN_RESOURCE_RULES_PATH = ' + buildOpts.codeSignResourceRules + '\n';
events.emit('verbose', 'Set CODE_SIGN_RESOURCE_RULES_PATH to ' + buildOpts.codeSignResourceRules + '.');
project.xcode.updateBuildProperty('CODE_SIGN_RESOURCE_RULES_PATH', buildOpts.codeSignResourceRules);
}

if (buildOpts.provisioningProfile) {
extraConfig += 'PROVISIONING_PROFILE = ' + buildOpts.provisioningProfile + '\n';
events.emit('verbose', 'Set PROVISIONING_PROFILE to ' + buildOpts.provisioningProfile + '.');
project.xcode.updateBuildProperty('PROVISIONING_PROFILE', `"${buildOpts.provisioningProfile}"`);

events.emit('verbose', 'Set CODE_SIGN_STYLE to Manual.');
project.xcode.updateBuildProperty('CODE_SIGN_STYLE', 'Manual');
project.xcode.addTargetAttribute('ProvisioningStyle', 'Manual');
}

if (buildOpts.developmentTeam) {
extraConfig += 'DEVELOPMENT_TEAM = ' + buildOpts.developmentTeam + '\n';
events.emit('verbose', 'Set DEVELOPMENT_TEAM to ' + buildOpts.developmentTeam + '.');
project.xcode.updateBuildProperty('DEVELOPMENT_TEAM', buildOpts.developmentTeam);
}
return Q.nfcall(fs.writeFile, path.join(__dirname, '..', 'build-extras.xcconfig'), extraConfig, 'utf-8');

return Q.nfcall(fs.writeFile, locations.pbxproj, project.xcode.writeSync(), 'utf-8');
}).then(function () {
var configuration = buildOpts.release ? 'Release' : 'Debug';

Expand Down

0 comments on commit 6e65f22

Please sign in to comment.