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/11/05 16:26:53 UTC

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

dpogue 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_r342660420
 
 

 ##########
 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 think `projectName` or `targetName` would be better for this variable than `displayName`. There was already some confusion about whether this was supposed to be set to the application name or the application short (display) name.

----------------------------------------------------------------
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