This is an automated email from the ASF dual-hosted git repository. erisu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cordova-node-xcode.git
The following commit(s) were added to refs/heads/master by this push: new cd6f86f Add targetName to paramter to getBuildProperty (#109) cd6f86f is described below commit cd6f86f9ab0d53bf07e1ad405226bd1e2d8772ca Author: Niklas Merz <niklasm...@apache.org> AuthorDate: Thu May 14 08:37:08 2020 +0200 Add targetName to paramter to getBuildProperty (#109) * Add targetName to parameter to getBuildProperty * Update lib/pbxProject.js Co-authored-by: Tim Brust <git...@timbrust.de> --- lib/pbxProject.js | 25 ++++++++++++++++++++++++- test/pbxProject.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/lib/pbxProject.js b/lib/pbxProject.js index d39bf8d..068548a 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -2068,11 +2068,34 @@ pbxProject.prototype.removeFile = function (path, group, opt) { -pbxProject.prototype.getBuildProperty = function(prop, build) { +pbxProject.prototype.getBuildProperty = function(prop, build, targetName) { var target; + let validConfigs = []; + + if (targetName) { + const target = this.pbxTargetByName(targetName); + const targetBuildConfigs = target && target.buildConfigurationList; + + const xcConfigList = this.pbxXCConfigurationList(); + + // Collect the UUID's from the configuration of our target + for (const configName in xcConfigList) { + if (!COMMENT_KEY.test(configName) && targetBuildConfigs === configName) { + const buildVariants = xcConfigList[configName].buildConfigurations; + + for (const item of buildVariants) { + validConfigs.push(item.value); + } + + break; + } + } + } + var configs = this.pbxXCBuildConfigurationSection(); for (var configName in configs) { if (!COMMENT_KEY.test(configName)) { + if (targetName && !validConfigs.includes(configName)) continue; var config = configs[configName]; if ( (build && config.name === build) || (build === undefined) ) { if (config.buildSettings[prop] !== undefined) { diff --git a/test/pbxProject.js b/test/pbxProject.js index 96efc26..aca2927 100644 --- a/test/pbxProject.js +++ b/test/pbxProject.js @@ -214,6 +214,34 @@ exports['updateBuildProperty function'] = { } } +exports['getBuildProperty function'] = { + setUp:function(callback) { + callback(); + }, + tearDown:function(callback) { + fs.writeFileSync(bcpbx, original_pbx, 'utf-8'); + callback(); + }, + 'should change all targets in .pbxproj with multiple targets': function (test) { + var myProj = new pbx('test/parser/projects/multitarget.pbxproj'); + myProj.parse(function(err, hash) { + myProj.updateBuildProperty('PRODUCT_BUNDLE_IDENTIFIER', 'comcompanytest'); + myProj.writeSync(); + test.ok(myProj.getBuildProperty('PRODUCT_BUNDLE_IDENTIFIER') === 'comcompanytest'); + test.done(); + }); + }, + 'should change only one target in .pbxproj with multiple targets': function (test) { + var myProj = new pbx('test/parser/projects/multitarget.pbxproj'); + myProj.parse(function(err, hash) { + myProj.updateBuildProperty('PRODUCT_BUNDLE_IDENTIFIER', 'comcompanytest', null, 'MultiTargetTest'); + myProj.writeSync(); + test.ok(myProj.getBuildProperty('PRODUCT_BUNDLE_IDENTIFIER', undefined, 'MultiTargetTest') === 'comcompanytest'); + test.done(); + }); + } +} + exports['addBuildProperty function'] = { setUp:function(callback) { callback(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org