You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/12/16 18:46:13 UTC

[GitHub] [cordova-ios] brodybits commented on a change in pull request #708: Do not overwrite all targets with same id (minimal)

brodybits commented on a change in pull request #708: Do not overwrite all targets with same id (minimal)
URL: https://github.com/apache/cordova-ios/pull/708#discussion_r358401287
 
 

 ##########
 File path: bin/templates/scripts/cordova/lib/prepare.js
 ##########
 @@ -274,12 +274,54 @@ function handleOrientationSettings (platformConfig, infoPlist) {
     }
 }
 
+// Make sure only update properties from our target project
+function updateBuildPropertyLocal (proj, displayName, prop, value, build) {
+    try {
+        // Check if we have a valid target - during prepare we do not have it
+        var target = proj.pbxTargetByName(displayName);
+        if (target == null || target.buildConfigurationList == null) {
+            proj.updateBuildProperty(prop, value, build);
+        } else {
+            var targetProjectBuildReference = target.buildConfigurationList;
+            // Collect the uuid's from the configuration of our target
+            var COMMENT_KEY = /_comment$/;
+            var validConfigs = [];
+            var configList = proj.pbxXCConfigurationList();
+            for (var configName in configList) {
+                if (!COMMENT_KEY.test(configName) && targetProjectBuildReference === configName) {
+                    var buildVariants = configList[configName].buildConfigurations;
+                    for (var i = 0; i < buildVariants.length; i++) {
+                        validConfigs.push(buildVariants[i].value);
+                    }
+                    break;
+                }
+            }
+            // Only update target props
+            var configs = proj.pbxXCBuildConfigurationSection();
+            for (configName in configs) {
+                if (!COMMENT_KEY.test(configName)) {
+                    if (validConfigs.indexOf(configName) === -1) {
+                        continue;
+                    }
+                    var config = configs[configName];
+                    if ((build && config.name === build) || (!build)) {
+                        config.buildSettings[prop] = value;
+                    }
+                }
+            }
+        }
+    } catch (e) { // fallback to default behavior on error
+        proj.updateBuildProperty(prop, value, build);
+    }
+}
+
 function handleBuildSettings (platformConfig, locations, infoPlist) {
     var pkg = platformConfig.getAttribute('ios-CFBundleIdentifier') || platformConfig.packageName();
     var targetDevice = parseTargetDevicePreference(platformConfig.getPreference('target-device', 'ios'));
     var deploymentTarget = platformConfig.getPreference('deployment-target', 'ios');
     var needUpdatedBuildSettingsForLaunchStoryboard = checkIfBuildSettingsNeedUpdatedForLaunchStoryboard(platformConfig, infoPlist);
     var swiftVersion = platformConfig.getPreference('SwiftVersion', 'ios');
+    var displayName = platformConfig.name().replace(/"/g, '');
 
 Review comment:
   I do not follow the arguments 100%. One thing is that one of the code references seems to point into a fork, please point into the code in our repos whenever possible.
   
   @NiklasMerz can you please give a quick explanation of what this variable means?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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