From ab061642d0200535400657b3138d35e4d150ee1e Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Fri, 24 Jan 2014 10:00:24 -0800 Subject: [PATCH 1/2] finish locale udid fix (fix #1773) --- lib/devices/ios/ios.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/devices/ios/ios.js b/lib/devices/ios/ios.js index 839584417..e6287b3fe 100644 --- a/lib/devices/ios/ios.js +++ b/lib/devices/ios/ios.js @@ -403,9 +403,12 @@ IOS.prototype.setLocale = function(cb) { logger.error(msg); cb(new Error(msg)); } - } else { + } else if (this.udid) { logger.info("Not setting locale because we're using a real device"); cb(); + } else { + logger.info("Not setting locale"); + cb(); } }; From 6b637d8aa8160e29d3c5fade9838eb1bd8f1efc1 Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Fri, 24 Jan 2014 13:47:03 -0800 Subject: [PATCH 2/2] make sure we don't crash if IDevice init fails --- lib/devices/ios/ios.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/devices/ios/ios.js b/lib/devices/ios/ios.js index e6287b3fe..1c4ead9a7 100644 --- a/lib/devices/ios/ios.js +++ b/lib/devices/ios/ios.js @@ -19,11 +19,12 @@ var path = require('path') , iOSLog = require('./ios-log.js') , iOSCrashLog = require('./ios-crash-log.js') , status = require("../../server/status.js") - , IDevice = require('node-idevice') + , iDevice = require('node-idevice') , async = require('async') , iOSController = require('./ios-controller.js') , iOSHybrid = require('./ios-hybrid.js') , settings = require('./settings.js') + , fruitstrap = path.resolve(__dirname, '../../../build/fruitstrap/fruitstrap') , UnknownError = errors.UnknownError; // XML Plist library helper @@ -499,7 +500,11 @@ IOS.prototype.installToRealDevice = function (cb) { logger.error(msg); cb(new Error(msg)); } else if (this.app) { - this.realDevice = new IDevice(this.udid); + try { + this.realDevice = this.getIDeviceObj(); + } catch (e) { + return cb(e); + } this.installApp(this.app, cb); } else { logger.debug("Real device specified but no ipa or app path, assuming bundle ID is " + @@ -522,20 +527,30 @@ IOS.prototype.installSafariLauncher = function(cb) { }.bind(this)); }; -IOS.prototype.installIpa = function(cb) { - logger.info("Installing ipa found at " + this.ipa); + +IOS.prototype.getIDeviceObj = function() { var idiPath = path.resolve(__dirname, "../../../build/", "libimobiledevice-macosx/ideviceinstaller"); + logger.info("Creating iDevice object with udid " + this.udid); try { - this.realDevice = new IDevice(this.udid); + this.realDevice = iDevice(this.udid); } catch (e1) { - logger.info("Couldn't find ideviceinstaller, trying built-in"); + logger.info("Couldn't find ideviceinstaller, trying built-in at " + + idiPath); try { - this.realDevice = new IDevice(this.udid, {cmd: idiPath}); + this.realDevice = iDevice(this.udid, {cmd: idiPath}); } catch (e2) { - return cb(e2); + var msg = "Could not initialize ideviceinstaller; make sure it is " + + "installed and works on your system"; + logger.error(msg); + throw new Error(msg); } } +}; + +IOS.prototype.installIpa = function(cb) { + logger.info("Installing ipa found at " + this.ipa); + this.realDevice = this.getIDeviceObj(); var d = this.realDevice; async.waterfall([ function (cb) { d.isInstalled(this.bundleId, cb); }.bind(this), @@ -970,7 +985,7 @@ IOS.prototype.push = function(elem) { IOS.prototype.isAppInstalled = function(bundleId, cb) { if (this.udid) { - var isInstalledCommand = 'build/fruitstrap/fruitstrap isInstalled --id ' + this.udid + ' --bundle ' + bundleId; + var isInstalledCommand = fruitstrap + ' isInstalled --id ' + this.udid + ' --bundle ' + bundleId; deviceCommon.isAppInstalled(isInstalledCommand, cb); } else { cb(new Error("You can not call isInstalled for the iOS simulator!")); @@ -979,7 +994,7 @@ IOS.prototype.isAppInstalled = function(bundleId, cb) { IOS.prototype.removeApp = function(bundleId, cb) { if (this.udid) { - var removeCommand = 'build/fruitstrap/fruitstrap uninstall --id ' + this.udid + ' --bundle ' + bundleId; + var removeCommand = fruitstrap + ' uninstall --id ' + this.udid + ' --bundle ' + bundleId; deviceCommon.removeApp(removeCommand, this.udid, bundleId, cb); } else { cb(new Error("You can not call removeApp for the iOS simulator!")); @@ -988,7 +1003,7 @@ IOS.prototype.removeApp = function(bundleId, cb) { IOS.prototype.installApp = function(unzippedAppPath, cb) { if (this.udid) { - var installationCommand = 'build/fruitstrap/fruitstrap install --id ' + this.udid + ' --bundle ' + unzippedAppPath; + var installationCommand = fruitstrap + ' install --id ' + this.udid + ' --bundle ' + unzippedAppPath; deviceCommon.installApp(installationCommand, this.udid, unzippedAppPath, cb); } else { cb(new Error("You can not call installApp for the iOS simulator!"));