This is an automated email from the ASF dual-hosted git repository. shazron pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cordova-ios.git
The following commit(s) were added to refs/heads/master by this push: new c2cab27 Fixes $(PRODUCT_BUNDLE_IDENTIFIER) not being resolved for a product archive (#494) c2cab27 is described below commit c2cab2730cd87f3830d22f5b7e09113e2e98ae18 Author: Shazron Abdullah <shaz...@gmail.com> AuthorDate: Mon Jan 14 13:29:00 2019 +0800 Fixes $(PRODUCT_BUNDLE_IDENTIFIER) not being resolved for a product archive (#494) * Fix shelljs error in not removing symlinks during run command * Changed build settings in Xcode project for a manual build - If a provisioning profile is set, set CODE_SIGN_STYLE build setting to 'Manual' - If a provisioning profile is set, set ProvisioningStyle target attribute to 'Manual' - if provisioning profile is NOT set AND 'automaticProvisioning' build option is set to TRUE, reverse the manual settings from above to 'Automatic' --- bin/templates/scripts/cordova/lib/build.js | 67 ++++++++++++++++++++++++++---- bin/templates/scripts/cordova/lib/run.js | 3 +- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js index 80a6111..045594b 100644 --- a/bin/templates/scripts/cordova/lib/build.js +++ b/bin/templates/scripts/cordova/lib/build.js @@ -30,9 +30,6 @@ var projectFile = require('./projectFile'); var events = require('cordova-common').events; -var projectPath = path.join(__dirname, '..', '..'); -var projectName = null; - // These are regular expressions to detect if the user is changing any of the built-in xcodebuildArgs /* eslint-disable no-useless-escape */ var buildFlagMatchers = { @@ -48,6 +45,40 @@ var buildFlagMatchers = { /* eslint-enable no-useless-escape */ /** + * Creates a project object (see projectFile.js/parseProjectFile) from + * a project path and name + * + * @param {*} projectPath + * @param {*} projectName + */ +function createProjectObject (projectPath, projectName) { + var locations = { + root: projectPath, + pbxproj: path.join(projectPath, projectName + '.xcodeproj', 'project.pbxproj') + }; + + return projectFile.parse(locations); +} + +/** + * Gets the resolved bundle identifier from a project. + * Resolves the variable set in INFO.plist, if any (simple case) + * + * @param {*} projectObject + */ +function getBundleIdentifier (projectObject) { + var packageName = projectObject.getPackageName(); + var bundleIdentifier = packageName; + + var variables = packageName.match(/\$\((\w+)\)/); // match $(VARIABLE), if any + if (variables && variables.length >= 2) { + bundleIdentifier = projectObject.xcode.getBuildProperty(variables[1]); + } + + return bundleIdentifier; +} + +/** * Returns a promise that resolves to the default simulator target; the logic here * matches what `cordova emulate ios` does. * @@ -74,6 +105,8 @@ function getDefaultSimulatorTarget () { module.exports.run = function (buildOpts) { var emulatorTarget = ''; + var projectPath = path.join(__dirname, '..', '..'); + var projectName = ''; buildOpts = buildOpts || {}; @@ -157,6 +190,26 @@ module.exports.run = function (buildOpts) { if (buildOpts.developmentTeam) { extraConfig += 'DEVELOPMENT_TEAM = ' + buildOpts.developmentTeam + '\n'; } + + function writeCodeSignStyle (value) { + var project = createProjectObject(projectPath, projectName); + + events.emit('verbose', `Set CODE_SIGN_STYLE Build Property to ${value}.`); + project.xcode.updateBuildProperty('CODE_SIGN_STYLE', value); + events.emit('verbose', `Set ProvisioningStyle Target Attribute to ${value}.`); + project.xcode.addTargetAttribute('ProvisioningStyle', value); + + project.write(); + } + + if (buildOpts.provisioningProfile) { + events.emit('verbose', 'ProvisioningProfile build option set, changing project settings to Manual.'); + writeCodeSignStyle('Manual'); + } else if (buildOpts.automaticProvisioning) { + events.emit('verbose', 'ProvisioningProfile build option NOT set, changing project settings to Automatic.'); + writeCodeSignStyle('Automatic'); + } + return Q.nfcall(fs.writeFile, path.join(__dirname, '..', 'build-extras.xcconfig'), extraConfig, 'utf-8'); }).then(function () { var configuration = buildOpts.release ? 'Release' : 'Debug'; @@ -178,12 +231,8 @@ module.exports.run = function (buildOpts) { return; } - var locations = { - root: projectPath, - pbxproj: path.join(projectPath, projectName + '.xcodeproj', 'project.pbxproj') - }; - - var bundleIdentifier = projectFile.parse(locations).getPackageName(); + var project = createProjectObject(projectPath, projectName); + var bundleIdentifier = getBundleIdentifier(project); var exportOptions = {'compileBitcode': false, 'method': 'development'}; if (buildOpts.packageType) { diff --git a/bin/templates/scripts/cordova/lib/run.js b/bin/templates/scripts/cordova/lib/run.js index a51882e..f9e5761 100644 --- a/bin/templates/scripts/cordova/lib/run.js +++ b/bin/templates/scripts/cordova/lib/run.js @@ -24,6 +24,7 @@ var build = require('./build'); var shell = require('shelljs'); var superspawn = require('cordova-common').superspawn; var check_reqs = require('./check_reqs'); +var fs = require('fs-extra'); var events = require('cordova-common').events; @@ -88,7 +89,7 @@ module.exports.run = function (runOptions) { var payloadFolder = path.join(buildOutputDir, 'Payload'); // delete the existing platform/ios/build/device/appname.app - shell.rm('-rf', appFile); + fs.removeSync(appFile); // move the platform/ios/build/device/Payload/appname.app to parent shell.mv('-f', appFileInflated, buildOutputDir); // delete the platform/ios/build/device/Payload folder --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org