You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2020/04/19 13:11:53 UTC

[cordova-node-xcode] branch getBuildProperty created (now 0b42b75)

This is an automated email from the ASF dual-hosted git repository.

niklasmerz pushed a change to branch getBuildProperty
in repository https://gitbox.apache.org/repos/asf/cordova-node-xcode.git.


      at 0b42b75  Add targetName to paramter to getBuildProperty

This branch includes the following new commits:

     new 0b42b75  Add targetName to paramter to getBuildProperty

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[cordova-node-xcode] 01/01: Add targetName to paramter to getBuildProperty

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

niklasmerz pushed a commit to branch getBuildProperty
in repository https://gitbox.apache.org/repos/asf/cordova-node-xcode.git

commit 0b42b75e6ccf22b803aced0c564fd1b95a405d83
Author: Niklas Merz <ni...@apache.org>
AuthorDate: Sun Apr 19 15:11:22 2020 +0200

    Add targetName to paramter to getBuildProperty
    
    Allow to get property only of one target similar to updateBuildProperty.
    
    Closes #108
---
 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..8c6516a 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-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org