mirror of
https://github.com/appium/appium.git
synced 2026-02-12 04:50:08 -06:00
Merge pull request #1809 from jlipps/master
fix some ios real device launch issues
This commit is contained in:
@@ -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
|
||||
@@ -403,9 +404,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();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -496,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 " +
|
||||
@@ -519,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),
|
||||
@@ -967,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!"));
|
||||
@@ -976,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!"));
|
||||
@@ -985,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!"));
|
||||
|
||||
Reference in New Issue
Block a user