Merge pull request #1161 from penguinho/udidetect

Adding automatic udid detection to iOS
This commit is contained in:
Dan Cuellar
2013-09-14 18:00:08 -07:00
5 changed files with 38 additions and 1 deletions

3
.gitmodules vendored
View File

@@ -16,3 +16,6 @@
[submodule "submodules/io.appium.gappium.sampleapp"]
path = submodules/io.appium.gappium.sampleapp
url = https://github.com/appium/io.appium.gappium.sampleapp.git
[submodule "submodules/udidetect"]
path = submodules/udidetect
url = https://github.com/vaskas/udidetect.git

View File

@@ -251,6 +251,7 @@ IOS.prototype.start = function(cb, onDie) {
async.series([
function (cb) { this.cleanup(cb); }.bind(this),
function (cb) { this.detectUdid(cb); }.bind(this),
function (cb) { this.parseLocalizableStrings(cb); }.bind(this),
function (cb) { this.setDeviceType(cb); }.bind(this),
function (cb) { this.installToRealDevice(cb); }.bind(this),
@@ -259,6 +260,28 @@ IOS.prototype.start = function(cb, onDie) {
}
};
IOS.prototype.detectUdid = function (cb) {
if (this.udid !== null && this.udid == "auto") {
logger.info("Auto-detecting iOS udid...");
var udidetectPath = path.resolve(__dirname, "../build/udidetect/udidetect");
var udiddetectProc = exec(udidetectPath, { maxBuffer: 524288, timeout: 3000 }, function(err, stdout) {
if (stdout && stdout.length > 2) {
this.udid = stdout.replace("\n","");
logger.info("Detected udid as " + this.udid);
} else {
logger.error("Could not detect udid.");
}
cb();
}.bind(this));
udiddetectProc.on('timeout', function () {
logger.error("Timed out trying to detect udid.");
});
} else {
cb();
}
};
IOS.prototype.installToRealDevice = function (cb) {
if (this.udid && this.ipa && this.bundleId) {
logger.info("Installing ipa found at " + this.ipa);

View File

@@ -11,7 +11,7 @@ All flags are optional, but some are required in conjunction with certain others
|`--app`|null|IOS: abs path to simulator-compiled .app file or the bundle_id of the desired target on device; Android: abs path to .apk file|`--app /abs/path/to/my.app`|
|`--ipa`|null|(IOS-only) abs path to compiled .ipa file|`--ipa /abs/path/to/my.ipa`|
|`-q`, `--quiet`|false|Don't use verbose logging output||
|`-U`, `--udid`|null|Unique device identifier of the connected physical device|`--udid 1adsf-sdfas-asdf-123sdf`|
|`-U`, `--udid`|null|Unique device identifier of the connected physical device|`--udid 1adsf-sdfas-asdf-123sdf` or `auto` to auto-detect|
|`-a`, `--address`|0.0.0.0|IP Address to listen on|`--address 0.0.0.0`|
|`-p`, `--port`|4723|port to listen on|`--port 4723`|
|`-dp`, `--device-port`|4724|(Android-only) port to connect to device on|`--device-port 4724`|

View File

@@ -84,6 +84,16 @@ reset_ios() {
run_cmd rm -rf build/iwd
run_cmd mkdir build/iwd
run_cmd cp -R submodules/instruments-without-delay/build/* build/iwd
echo "* Cloning/updating udidetect"
run_cmd git submodule update --init submodules/udidetect
echo "* Building udidetect"
run_cmd pushd submodules/udidetect
run_cmd make
run_cmd popd
echo "* Moving udidetect into build/udidetect"
run_cmd rm -rf build/udidetect
run_cmd mkdir build/udidetect
run_cmd cp -R submodules/udidetect/udidetect build/udidetect/
if $include_dev ; then
if $hardcore ; then
echo "* Clearing out old UICatalog download"

1
submodules/udidetect Submodule

Submodule submodules/udidetect added at 518dbdf0b6