From 6e65f22a0fc0870b32d55def0d528687824e5fae Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Thu, 10 Jan 2019 23:41:36 -0800 Subject: [PATCH] Update build.js to set Xcodeproj properties --- bin/templates/scripts/cordova/lib/build.js | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js index 80a6111715..dafa6f467e 100644 --- a/bin/templates/scripts/cordova/lib/build.js +++ b/bin/templates/scripts/cordova/lib/build.js @@ -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';