You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2018/02/26 05:47:52 UTC

[cordova-ios] branch master updated: CB-12940: [IOS] Use deployment-target from config.xml for platform version in Podfile (#335)

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

shazron 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 f8a817b  CB-12940: [IOS] Use deployment-target from config.xml for platform version in Podfile (#335)
f8a817b is described below

commit f8a817bc8e7c1925c0c4ec7b474ec2ce48f1643d
Author: Shazron Abdullah <sh...@gmail.com>
AuthorDate: Mon Feb 26 13:47:50 2018 +0800

    CB-12940: [IOS] Use deployment-target from config.xml for platform version in Podfile (#335)
---
 bin/templates/scripts/cordova/Api.js         | 6 ++++--
 bin/templates/scripts/cordova/lib/Podfile.js | 7 ++++---
 tests/spec/unit/Api.spec.js                  | 6 +++---
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/bin/templates/scripts/cordova/Api.js b/bin/templates/scripts/cordova/Api.js
index 04da4a1..bc5f10a 100644
--- a/bin/templates/scripts/cordova/Api.js
+++ b/bin/templates/scripts/cordova/Api.js
@@ -30,6 +30,7 @@ var events = require('cordova-common').events;
 var PluginManager = require('cordova-common').PluginManager;
 var Q = require('q');
 var util = require('util');
+var ConfigParser = require('cordova-common').ConfigParser;
 
 function setupEvents (externalEventEmitter) {
     if (externalEventEmitter) {
@@ -179,7 +180,7 @@ Api.prototype.getPlatformInfo = function () {
     result.root = this.root;
     result.name = this.platform;
     result.version = require('./version');
-    result.projectConfig = this._config;
+    result.projectConfig = new ConfigParser(this.locations.configXml);
 
     return result;
 };
@@ -247,6 +248,7 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
 
             var project_dir = self.locations.root;
             var project_name = self.locations.xcodeCordovaProj.split('/').pop();
+            var minDeploymentTarget = self.getPlatformInfo().projectConfig.getPreference('deployment-target', 'ios');
 
             var Podfile = require('./lib/Podfile').Podfile;
             var PodsJson = require('./lib/PodsJson').PodsJson;
@@ -254,7 +256,7 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
             events.emit('verbose', 'Adding pods since the plugin contained <framework>(s) with type="podspec"');
 
             var podsjsonFile = new PodsJson(path.join(project_dir, PodsJson.FILENAME));
-            var podfileFile = new Podfile(path.join(project_dir, Podfile.FILENAME), project_name);
+            var podfileFile = new Podfile(path.join(project_dir, Podfile.FILENAME), project_name, minDeploymentTarget);
 
             frameworkPods.forEach(function (obj) {
                 var podJson = {
diff --git a/bin/templates/scripts/cordova/lib/Podfile.js b/bin/templates/scripts/cordova/lib/Podfile.js
index 13e6180..ffa5be2 100644
--- a/bin/templates/scripts/cordova/lib/Podfile.js
+++ b/bin/templates/scripts/cordova/lib/Podfile.js
@@ -28,11 +28,12 @@ var CordovaError = require('cordova-common').CordovaError;
 
 Podfile.FILENAME = 'Podfile';
 
-function Podfile (podFilePath, projectName) {
+function Podfile (podFilePath, projectName, minDeploymentTarget) {
     this.podToken = '##INSERT_POD##';
 
     this.path = podFilePath;
     this.projectName = projectName;
+    this.minDeploymentTarget = minDeploymentTarget || '9.0';
     this.contents = null;
     this.pods = null;
     this.__dirty = false;
@@ -97,12 +98,12 @@ Podfile.prototype.getTemplate = function () {
     var projectName = this.escapeSingleQuotes(this.projectName);
     return util.format(
         '# DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
-            'platform :ios, \'9.0\'\n' +
+            'platform :ios, \'%s\'\n' +
             'target \'%s\' do\n' +
             '\tproject \'%s.xcodeproj\'\n' +
             '%s\n' +
             'end\n',
-        projectName, projectName, this.podToken);
+        this.minDeploymentTarget, projectName, projectName, this.podToken);
 };
 
 Podfile.prototype.addSpec = function (name, spec) {
diff --git a/tests/spec/unit/Api.spec.js b/tests/spec/unit/Api.spec.js
index 14e178e..eef7f72 100644
--- a/tests/spec/unit/Api.spec.js
+++ b/tests/spec/unit/Api.spec.js
@@ -127,13 +127,13 @@ describe('Platform Api', function () {
 
     describe('.prototype', function () {
         var api;
-        var projectRoot = '/some/path';
+        var projectRoot = iosProjectFixture;
         beforeEach(function () {
-            spyOn(fs, 'readdirSync').and.returnValue([projectRoot + '/cordova.xcodeproj']);
+            api = new Api('ios', projectRoot);
+            spyOn(fs, 'readdirSync').and.returnValue([api.locations.xcodeProjDir]);
             spyOn(projectFile, 'parse').and.returnValue({
                 getPackageName: function () { return 'ios.cordova.io'; }
             });
-            api = new Api('ios', projectRoot);
         });
 
         // See the comment at the top of this file, in the list of requires,

-- 
To stop receiving notification emails like this one, please contact
shazron@apache.org.

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