You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2019/03/02 22:49:29 UTC

[cordova-ios] branch master updated: ignore swift version settings of cocoapods library on windows/linux environment by using check_reqs.check_cocoapods function

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

dpogue 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 ae4d1fd  ignore swift version settings of cocoapods library on windows/linux environment by using check_reqs.check_cocoapods function
ae4d1fd is described below

commit ae4d1fdc5e122b815118e64b04015ffcb0e47f4b
Author: knaito <kn...@asial.co.jp>
AuthorDate: Thu Feb 14 14:17:46 2019 +0900

    ignore swift version settings of cocoapods library on windows/linux environment by using check_reqs.check_cocoapods function
---
 bin/templates/scripts/cordova/Api.js | 74 +++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 34 deletions(-)

diff --git a/bin/templates/scripts/cordova/Api.js b/bin/templates/scripts/cordova/Api.js
index bffcb7e..7059c18 100644
--- a/bin/templates/scripts/cordova/Api.js
+++ b/bin/templates/scripts/cordova/Api.js
@@ -445,7 +445,7 @@ Api.prototype.addPodSpecs = function (plugin, podSpecs, frameworkPods) {
 
             return podfileFile.install(check_reqs.check_cocoapods)
                 .then(function () {
-                    self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
+                    return self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
                 });
         } else {
             events.emit('verbose', 'Podfile unchanged, skipping `pod install`');
@@ -564,7 +564,7 @@ Api.prototype.removePodSpecs = function (plugin, podSpecs, frameworkPods) {
 
             return podfileFile.install(check_reqs.check_cocoapods)
                 .then(function () {
-                    self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
+                    return self.setSwiftVersionForCocoaPodsLibraries(podsjsonFile);
                 });
         } else {
             events.emit('verbose', 'Podfile unchanged, skipping `pod install`');
@@ -582,41 +582,47 @@ Api.prototype.removePodSpecs = function (plugin, podSpecs, frameworkPods) {
 Api.prototype.setSwiftVersionForCocoaPodsLibraries = function (podsjsonFile) {
     var self = this;
     var __dirty = false;
-    var podPbxPath = path.join(self.root, 'Pods', 'Pods.xcodeproj', 'project.pbxproj');
-    var podXcodeproj = xcode.project(podPbxPath);
-    podXcodeproj.parseSync();
-    var podTargets = podXcodeproj.pbxNativeTargetSection();
-    var podConfigurationList = podXcodeproj.pbxXCConfigurationList();
-    var podConfigs = podXcodeproj.pbxXCBuildConfigurationSection();
-
-    var libraries = podsjsonFile.getLibraries();
-    Object.keys(libraries).forEach(function (key) {
-        var podJson = libraries[key];
-        var name = podJson.name;
-        var swiftVersion = podJson['swift-version'];
-        if (swiftVersion) {
-            __dirty = true;
-            Object.keys(podTargets).filter(function (targetKey) {
-                return podTargets[targetKey].productName === name;
-            }).map(function (targetKey) {
-                return podTargets[targetKey].buildConfigurationList;
-            }).map(function (buildConfigurationListId) {
-                return podConfigurationList[buildConfigurationListId];
-            }).map(function (buildConfigurationList) {
-                return buildConfigurationList.buildConfigurations;
-            }).reduce(function (acc, buildConfigurations) {
-                return acc.concat(buildConfigurations);
-            }, []).map(function (buildConfiguration) {
-                return buildConfiguration.value;
-            }).forEach(function (buildId) {
-                __dirty = true;
-                podConfigs[buildId].buildSettings['SWIFT_VERSION'] = swiftVersion;
+    return check_reqs.check_cocoapods().then(function (toolOptions) {
+        if (toolOptions.ignore) {
+            events.emit('verbose', '=== skip Swift Version Settings For Cocoapods Libraries');
+        } else {
+            var podPbxPath = path.join(self.root, 'Pods', 'Pods.xcodeproj', 'project.pbxproj');
+            var podXcodeproj = xcode.project(podPbxPath);
+            podXcodeproj.parseSync();
+            var podTargets = podXcodeproj.pbxNativeTargetSection();
+            var podConfigurationList = podXcodeproj.pbxXCConfigurationList();
+            var podConfigs = podXcodeproj.pbxXCBuildConfigurationSection();
+
+            var libraries = podsjsonFile.getLibraries();
+            Object.keys(libraries).forEach(function (key) {
+                var podJson = libraries[key];
+                var name = podJson.name;
+                var swiftVersion = podJson['swift-version'];
+                if (swiftVersion) {
+                    __dirty = true;
+                    Object.keys(podTargets).filter(function (targetKey) {
+                        return podTargets[targetKey].productName === name;
+                    }).map(function (targetKey) {
+                        return podTargets[targetKey].buildConfigurationList;
+                    }).map(function (buildConfigurationListId) {
+                        return podConfigurationList[buildConfigurationListId];
+                    }).map(function (buildConfigurationList) {
+                        return buildConfigurationList.buildConfigurations;
+                    }).reduce(function (acc, buildConfigurations) {
+                        return acc.concat(buildConfigurations);
+                    }, []).map(function (buildConfiguration) {
+                        return buildConfiguration.value;
+                    }).forEach(function (buildId) {
+                        __dirty = true;
+                        podConfigs[buildId].buildSettings['SWIFT_VERSION'] = swiftVersion;
+                    });
+                }
             });
+            if (__dirty) {
+                fs.writeFileSync(podPbxPath, podXcodeproj.writeSync(), 'utf-8');
+            }
         }
     });
-    if (__dirty) {
-        fs.writeFileSync(podPbxPath, podXcodeproj.writeSync(), 'utf-8');
-    }
 };
 
 /**


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