cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [25/50] git commit: Explicitly fail on platform-add for ios if xcode is not installed or not of minimum requirements. Closes #52.
Date Wed, 28 Nov 2012 18:16:24 GMT
Explicitly fail on platform-add for ios if xcode is not installed or not of minimum requirements.
Closes #52.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/d7b39e83
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/d7b39e83
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/d7b39e83

Branch: refs/heads/master
Commit: d7b39e835e2e7bc90fd4f9f079344d5b4313294d
Parents: 40c06dd
Author: Fil Maj <maj.fil@gmail.com>
Authored: Wed Oct 24 17:10:50 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Wed Oct 24 17:10:50 2012 -0700

----------------------------------------------------------------------
 package.json          |    1 +
 spec/platform.spec.js |   12 ++++++++++++
 src/platform.js       |    9 +++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/d7b39e83/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index ec0249d..63e6232 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
     "ncallbacks":"1.0.0",
     "adm-zip":"0.1.8",
     "request":"2.11.4",
+    "semver":"1.1.0",
     "prompt":"0.2.7"
   },
   "devDependencies": {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/d7b39e83/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index e6f9425..da4b2e5 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -174,6 +174,18 @@ describe('platform command', function() {
                 cordova.platform('add', 'ios');
                 expect(s).toHaveBeenCalled();
             });
+            it('should error out if user does not have xcode 4.5 or above installed', function()
{
+                var s = spyOn(shell, 'exec').andReturn({code:0,output:'Xcode 4.2.1'});
+                expect(function() {
+                    cordova.platform('add', 'ios');
+                }).toThrow();
+            });
+            it('should error out if user does not have xcode installed at all', function()
{
+                var s = spyOn(shell, 'exec').andReturn({code:1});
+                expect(function() {
+                    cordova.platform('add', 'ios');
+                }).toThrow();
+            });
         });
         describe('blackberry-10', function() {
             it('should add a basic blackberry project', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/d7b39e83/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 3a9e4c6..01d6bc3 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -8,6 +8,7 @@ var config_parser = require('./config_parser'),
     ios_parser    = require('./metadata/ios_parser'),
     hooker        = require('./hooker'),
     n             = require('ncallbacks'),
+    semver        = require('semver'),
     shell         = require('shelljs');
 
 module.exports = function platform(command, targets, callback) {
@@ -44,6 +45,14 @@ module.exports = function platform(command, targets, callback) {
                 var output = path.join(projectRoot, 'platforms', target);
 
                 var shell_to_cordova = function() {
+                    if (target == 'ios') {
+                        // Check xcode + version.
+                        var xcode = shell.exec('xcodebuild -version', {silent:true});
+                        if (xcode.code != 0) throw 'Xcode is not installed. Cannot add iOS
platform.';
+                        var xc_version = xcode.output.split('\n')[0].split(' ')[1];
+                        var MIN_XCODE_VERSION = '4.5.x';
+                        if (semver.lt(xc_version, MIN_XCODE_VERSION)) throw ('Xcode version
installed is too old. Minimum: ' + MIN_XCODE_VERSION + ', yours: ' + xc_version);
+                    }
                     // Create a platform app using the ./bin/create scripts that exist in
each repo.
                     // TODO: eventually refactor to allow multiple versions to be created.
                     // Check if output directory already exists.


Mime
View raw message