From 6aa7b57014e0bebd234028547efbc14b1ec1d386 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Tue, 6 Oct 2015 17:46:50 -0700 Subject: [PATCH] Fixes #167 - On El Cap, detect Xcode 7 properly installed --- check_reqs.js | 32 ++++++++++++++++++++++++++++++++ package.json | 11 ++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 check_reqs.js diff --git a/check_reqs.js b/check_reqs.js new file mode 100755 index 0000000..fda89da --- /dev/null +++ b/check_reqs.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +var shell = require('shelljs'); +var util = require('util'); +var os = require('os'); + +var XCODEBUILD_MIN_VERSION = '6.4'; +var XCODEBUILD_NOT_FOUND_MESSAGE = + 'Please install Xcode version ' + XCODEBUILD_MIN_VERSION + ' or greater from App Store'; + +var tool = 'xcodebuild' +var tool_command = shell.which(tool); +if (!tool_command) { + console.log(tool + ' : ' + XCODEBUILD_NOT_FOUND_MESSAGE); + process.exit(1); +} + +shell.exec(tool + ' -version', { silent: true }, function(code, output) { + if (code === 0) { + var arr = output.match(/^Xcode (\d+\.\d+)/); + var ver = arr[1]; + + if (os.release() >= '15.0.0' && ver < '7.0') { + console.log(util.format('You need at least Xcode 7.0 on OS X 10.11 El Capitan (you have version %s)', ver)); + process.exit(1); + } + + if (ver < XCODEBUILD_MIN_VERSION) { + console.log(util.format('%s : %s. (you have version %s)', tool, XCODEBUILD_NOT_FOUND_MESSAGE, ver)); + } + } +}); \ No newline at end of file diff --git a/package.json b/package.json index 1a1f71d..564034a 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,22 @@ { "name": "ios-deploy", "version": "1.8.0", - "os" : [ "darwin" ], + "os": [ + "darwin" + ], "description": "launch iOS apps iOS devices from the command line (Xcode 7)", "main": "ios-deploy", "scripts": { - "preinstall": "make ios-deploy" + "preinstall": "./check_reqs.js && make ios-deploy" }, - "bin" : "./ios-deploy" , + "bin": "./ios-deploy", "repository": { "type": "git", "url": "https://github.com/phonegap/ios-deploy" }, + "dependencies": { + "shelljs": "^0.2.6" + }, "keywords": [ "ios-deploy", "deploy to iOS device"