New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ios-sim-portable

Package Overview
Dependencies
Maintainers
2
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ios-sim-portable - npm Package Compare versions

Comparing version 1.0.10-beta to 1.0.11-beta

lib/child-process.js

0

bin/ios-sim-portable.js
#!/usr/bin/env node
require("../lib/ios-sim.js");
//grunt-start
/// <reference path="child-process.ts" />
/// <reference path="command-executor.ts" />

@@ -15,7 +16,11 @@ /// <reference path="commands/device-types.ts" />

/// <reference path="ios-sim.ts" />
/// <reference path="iphone-interop-simulator-base.ts" />
/// <reference path="iphone-simulator-xcode-5.ts" />
/// <reference path="iphone-simulator-xcode-6.ts" />
/// <reference path="iphone-simulator-xcode-7.ts" />
/// <reference path="iphone-simulator.ts" />
/// <reference path="options.ts" />
/// <reference path="simctl.ts" />
/// <reference path="utils.ts" />
/// <reference path="xcode.ts" />
//grunt-end

@@ -0,0 +0,0 @@ ///<reference path="./.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path="./.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

2

lib/commands/launch.js

@@ -9,3 +9,3 @@ ///<reference path=".././.d.ts"/>

var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
return iphoneSimulator.run(args[0]);
return iphoneSimulator.run(args[0], args[1]);
};

@@ -12,0 +12,0 @@ return Command;

@@ -10,4 +10,4 @@ ///<reference path=".././.d.ts"/>

var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
return iphoneSimulator.run(args[0]);
return iphoneSimulator.run(args[0], args[1]);
}
}

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path=".././.d.ts"/>

///<reference path="./.d.ts"/>
"use strict";
//# sourceMappingURL=declarations.js.map

@@ -5,3 +5,3 @@ ///<reference path="./.d.ts"/>

interface IiPhoneSimulator {
run(appName: string): IFuture<void>;
run(applicationPath: string, applicationIdentifier: string): IFuture<void>;
printDeviceTypes(): IFuture<void>;

@@ -21,8 +21,18 @@ printSDKS(): IFuture<void>;

interface IDevice {
device: any; // nodobjc wrapper to device
deviceIdentifier: string;
fullDeviceIdentifier: string;
name: string;
id: string;
fullId: string;
runtimeVersion: string;
state?: string;
rawDevice?: any; // NodObjC wrapper to device
}
interface ISimctl {
launch(deviceId: string, applicationIdentifier: string): IFuture<void>;
install(deviceId: string, applicationPath: string): IFuture<void>;
uninstall(deviceId: string, applicationIdentifier: string): IFuture<void>;
notifyPost(deviceId: string, notification: string): IFuture<void>;
getDevices(): IFuture<IDevice[]>;
}
interface IDictionary<T> {

@@ -32,8 +42,14 @@ [key: string]: T;

interface ISimulator {
validDeviceIdentifiers: string[];
deviceIdentifiersInfo: string[];
interface IInteropSimulator {
getDevices(): IFuture<IDevice[]>;
setSimulatedDevice(config: any): void;
}
interface ISimulator {
getDevices(): IFuture<IDevice[]>;
getSdks(): IFuture<ISdk[]>;
run(applicationPath: string, applicationIdentifier: string): IFuture<void>;
sendNotification(notification: string): IFuture<void>;
}
interface IExecuteOptions {

@@ -48,3 +64,8 @@ canRunMainLoop: boolean;

rootPath: string;
sdkInfo(): string;
}
interface IXcodeVersionData {
major: string;
minor: string;
build: string;
}

@@ -0,0 +0,0 @@ // Type definitions for node-fibers

@@ -0,0 +0,0 @@ /************************************************

@@ -0,0 +0,0 @@ declare module "nodobjc" {

@@ -0,0 +0,0 @@ ///<reference path="./.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path="./.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path="./.d.ts"/>

@@ -0,0 +0,0 @@ ///<reference path="./.d.ts"/>

///<reference path="./.d.ts"/>
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Future = require("fibers/future");
var options = require("./options");
var $ = require("nodobjc");
var XCode5Simulator = (function () {
var iPhoneSimulatorBaseLib = require("./iphone-interop-simulator-base");
var XCode5Simulator = (function (_super) {
__extends(XCode5Simulator, _super);
function XCode5Simulator() {
_super.call(this, this);
}
Object.defineProperty(XCode5Simulator.prototype, "validDeviceIdentifiers", {
get: function () {
return _.keys(XCode5Simulator.allowedDeviceIdentifiers);
},
enumerable: true,
configurable: true
});
Object.defineProperty(XCode5Simulator.prototype, "deviceIdentifiersInfo", {
get: function () {
return _.keys(XCode5Simulator.allowedDeviceIdentifiers);
},
enumerable: true,
configurable: true
});
XCode5Simulator.prototype.getDevices = function () {
return (function () {
var devices = [];
_.each(_.keys(XCode5Simulator.allowedDeviceIdentifiers), function (deviceName) {
devices.push({
name: deviceName,
id: deviceName,
fullId: deviceName,
runtimeVersion: ""
});
});
return devices;
}).future()();
};
XCode5Simulator.prototype.getSdks = function () {
return (function () {
return [];
}).future()();
};
XCode5Simulator.prototype.setSimulatedDevice = function (config) {
config("setSimulatedDeviceInfoName", $(this.deviceIdentifier));
};
XCode5Simulator.prototype.sendNotification = function (notification) {
return Future.fromResult();
};
Object.defineProperty(XCode5Simulator.prototype, "deviceIdentifier", {

@@ -44,4 +61,4 @@ get: function () {

return XCode5Simulator;
})();
})(iPhoneSimulatorBaseLib.IPhoneInteropSimulatorBase);
exports.XCode5Simulator = XCode5Simulator;
//# sourceMappingURL=iphone-simulator-xcode-5.js.map

@@ -5,2 +5,3 @@ ///<reference path="./.d.ts"/>

import errors = require("./errors");
import Future = require("fibers/future");
import options = require("./options");

@@ -12,4 +13,10 @@ import utils = require("./utils");

export class XCode5Simulator implements ISimulator {
import iPhoneSimulatorBaseLib = require("./iphone-interop-simulator-base");
export class XCode5Simulator extends iPhoneSimulatorBaseLib.IPhoneInteropSimulatorBase implements IInteropSimulator {
constructor() {
super(this);
}
private static DEFAULT_DEVICE_IDENTIFIER = "iPhone";

@@ -27,8 +34,22 @@

public get validDeviceIdentifiers(): string[] {
return _.keys(XCode5Simulator.allowedDeviceIdentifiers);
public getDevices(): IFuture<IDevice[]> {
return (() => {
let devices: IDevice[] = [];
_.each(_.keys(XCode5Simulator.allowedDeviceIdentifiers), deviceName => {
devices.push({
name: deviceName,
id: deviceName,
fullId: deviceName,
runtimeVersion: ""
});
});
return devices;
}).future<IDevice[]>()();
}
public get deviceIdentifiersInfo(): string[] {
return _.keys(XCode5Simulator.allowedDeviceIdentifiers);
public getSdks(): IFuture<ISdk[]> {
return (() => {
return (<ISdk[]>[]);
}).future<ISdk[]>()();
}

@@ -40,6 +61,10 @@

public sendNotification(notification: string): IFuture<void> {
return Future.fromResult();
}
private get deviceIdentifier(): string {
var identifier = options.device || XCode5Simulator.DEFAULT_DEVICE_IDENTIFIER;
let identifier = options.device || XCode5Simulator.DEFAULT_DEVICE_IDENTIFIER;
return XCode5Simulator.allowedDeviceIdentifiers[identifier];
}
}
///<reference path="./.d.ts"/>
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var errors = require("./errors");
var options = require("./options");
var util = require("util");
var os = require("os");
var $ = require("nodobjc");
var XCode6Simulator = (function () {
var iPhoneSimulatorBaseLib = require("./iphone-interop-simulator-base");
var XCode6Simulator = (function (_super) {
__extends(XCode6Simulator, _super);
function XCode6Simulator() {
this.availableDevices = Object.create(null);
_super.call(this, this);
this.cachedDevices = null;
}
Object.defineProperty(XCode6Simulator.prototype, "validDeviceIdentifiers", {
XCode6Simulator.prototype.setSimulatedDevice = function (config) {
var device = this.getDeviceByName().rawDevice;
config("setDevice", device);
};
XCode6Simulator.prototype.getSimulatedDevice = function () {
return this.getDeviceByName().rawDevice;
};
XCode6Simulator.prototype.getDevices = function () {
var _this = this;
return this.execute(function () { return _this.devices; }, { canRunMainLoop: false });
};
XCode6Simulator.prototype.getSdks = function () {
var _this = this;
return this.execute(function () { return _this.sdks; }, { canRunMainLoop: false });
};
Object.defineProperty(XCode6Simulator.prototype, "devices", {
get: function () {
var devices = this.getDevicesInfo();
return _.map(devices, function (device) { return device.deviceIdentifier; });
if (!this.cachedDevices) {
this.cachedDevices = [];
var deviceSet = $.classDefinition.getClassByName("SimDeviceSet")("defaultSet");
var devices = deviceSet("availableDevices");
var count = devices("count");
if (count > 0) {
for (var index = 0; index < count; index++) {
var device = devices("objectAtIndex", index);
var deviceIdentifier = device("deviceType")("identifier").toString();
var deviceIdentifierPrefixIndex = deviceIdentifier.indexOf(XCode6Simulator.DEVICE_IDENTIFIER_PREFIX);
var deviceIdentifierWithoutPrefix = deviceIdentifier.substring(deviceIdentifierPrefixIndex + XCode6Simulator.DEVICE_IDENTIFIER_PREFIX.length + 1);
var runtimeVersion = device("runtime")("versionString").toString();
this.cachedDevices.push({
name: deviceIdentifierWithoutPrefix,
id: deviceIdentifierWithoutPrefix,
fullId: this.buildFullDeviceIdentifier(deviceIdentifier),
runtimeVersion: runtimeVersion,
rawDevice: device
});
}
}
}
return this.cachedDevices;
},

@@ -20,6 +63,16 @@ enumerable: true,

});
Object.defineProperty(XCode6Simulator.prototype, "deviceIdentifiersInfo", {
Object.defineProperty(XCode6Simulator.prototype, "sdks", {
get: function () {
var devices = this.getDevicesInfo();
return _.map(devices, function (device) { return util.format("Device Identifier: %s. %sRuntime Version: %s %s", device.fullDeviceIdentifier, os.EOL, device.runtimeVersion, os.EOL); });
var systemRootClass = $.classDefinition.getClassByName("DTiPhoneSimulatorSystemRoot");
var roots = systemRootClass("knownRoots");
var count = roots("count");
var sdks = [];
for (var index = 0; index < count; index++) {
var root = roots("objectAtIndex", index);
var displayName = root("sdkDisplayName").toString();
var version = root("sdkVersion").toString();
var rootPath = root("sdkRootPath").toString();
sdks.push({ displayName: displayName, version: version, rootPath: rootPath });
}
return sdks;
},

@@ -29,16 +82,17 @@ enumerable: true,

});
XCode6Simulator.prototype.setSimulatedDevice = function (config) {
var device = this.getDeviceByIdentifier(this.deviceIdentifier);
config("setDevice", device);
XCode6Simulator.prototype.sendNotification = function (notification) {
var _this = this;
var action = function () {
var device = _this.getSimulatedDevice();
if (!device) {
errors.fail("Could not find device.");
}
var result = device("postDarwinNotification", $(notification), "error", null);
if (!result) {
errors.fail("Could not send notification: " + notification);
}
};
return this.execute(action, { canRunMainLoop: false });
};
XCode6Simulator.prototype.getSimulatedDevice = function () {
return this.getDeviceByIdentifier(this.deviceIdentifier);
};
XCode6Simulator.prototype.getDevicesInfo = function () {
return _(this.getAvailableDevices())
.map(_.identity)
.flatten()
.value();
};
Object.defineProperty(XCode6Simulator.prototype, "deviceIdentifier", {
Object.defineProperty(XCode6Simulator.prototype, "deviceName", {
get: function () {

@@ -50,39 +104,11 @@ return options.device || XCode6Simulator.DEFAULT_DEVICE_IDENTIFIER;

});
XCode6Simulator.prototype.getAvailableDevices = function () {
if (_.isEmpty(this.availableDevices)) {
var deviceSet = $.classDefinition.getClassByName("SimDeviceSet")("defaultSet");
var devices = deviceSet("availableDevices");
var count = devices("count");
if (count > 0) {
for (var index = 0; index < count; index++) {
var device = devices("objectAtIndex", index);
var deviceIdentifier = device("deviceType")("identifier").toString();
var deviceIdentifierPrefixIndex = deviceIdentifier.indexOf(XCode6Simulator.DEVICE_IDENTIFIER_PREFIX);
var deviceIdentifierWithoutPrefix = deviceIdentifier.substring(deviceIdentifierPrefixIndex + XCode6Simulator.DEVICE_IDENTIFIER_PREFIX.length + 1);
var runtimeVersion = device("runtime")("versionString").toString();
if (!this.availableDevices[deviceIdentifier]) {
this.availableDevices[deviceIdentifier] = [];
}
this.availableDevices[deviceIdentifier].push({
device: device,
deviceIdentifier: deviceIdentifierWithoutPrefix,
fullDeviceIdentifier: this.buildFullDeviceIdentifier(deviceIdentifier),
runtimeVersion: runtimeVersion
});
}
}
XCode6Simulator.prototype.getDeviceByName = function () {
var _this = this;
var devices = this.getDevices().wait();
var device = _.find(devices, function (device) { return device.name === _this.deviceName; });
if (!device) {
errors.fail("Unable to find device with name ", this.deviceName);
}
return this.availableDevices;
return device;
};
XCode6Simulator.prototype.getDeviceByIdentifier = function (deviceIdentifier) {
var availableDevices = this.getAvailableDevices();
if (!_.isEmpty(availableDevices)) {
var fullDeviceIdentifier = this.buildFullDeviceIdentifier(deviceIdentifier);
var selectedDevice = availableDevices[fullDeviceIdentifier];
if (selectedDevice) {
return selectedDevice[0].device;
}
}
errors.fail("Unable to find device with identifier ", deviceIdentifier);
};
XCode6Simulator.prototype.buildFullDeviceIdentifier = function (deviceIdentifier) {

@@ -94,4 +120,4 @@ return util.format("%s.%s", XCode6Simulator.DEVICE_IDENTIFIER_PREFIX, deviceIdentifier);

return XCode6Simulator;
})();
})(iPhoneSimulatorBaseLib.IPhoneInteropSimulatorBase);
exports.XCode6Simulator = XCode6Simulator;
//# sourceMappingURL=iphone-simulator-xcode-6.js.map
///<reference path="./.d.ts"/>
"use strict";
import errors = require("./errors");
import options = require("./options");
import utils = require("./utils");
import util = require("util");
import os = require("os");
var $ = require("nodobjc");
import * as errors from "./errors";
import * as options from "./options";
import * as utils from "./utils";
import * as util from "util";
import * as os from "os";
let $ = require("nodobjc");
export class XCode6Simulator implements ISimulator {
import iPhoneSimulatorBaseLib = require("./iphone-interop-simulator-base");
export class XCode6Simulator extends iPhoneSimulatorBaseLib.IPhoneInteropSimulatorBase implements IInteropSimulator {
private static DEVICE_IDENTIFIER_PREFIX = "com.apple.CoreSimulator.SimDeviceType";
private static DEFAULT_DEVICE_IDENTIFIER = "iPhone-4s";
private cachedDevices: IDevice[];
private availableDevices: IDictionary<IDevice[]>;
constructor() {
this.availableDevices = Object.create(null);
}
super(this);
public get validDeviceIdentifiers(): string[] {
var devices = this.getDevicesInfo();
return _.map(devices, device => device.deviceIdentifier);
this.cachedDevices = null;
}
public get deviceIdentifiersInfo(): string[] {
var devices = this.getDevicesInfo();
return _.map(devices, device => util.format("Device Identifier: %s. %sRuntime Version: %s %s", device.fullDeviceIdentifier, os.EOL, device.runtimeVersion, os.EOL));
}
public setSimulatedDevice(config: any): void {
var device = this.getDeviceByIdentifier(this.deviceIdentifier);
let device = this.getDeviceByName().rawDevice;
config("setDevice", device);

@@ -38,40 +31,36 @@ }

public getSimulatedDevice(): any {
return this.getDeviceByIdentifier(this.deviceIdentifier);
return this.getDeviceByName().rawDevice;
}
private getDevicesInfo(): IDevice[] {
return <IDevice[]> _(this.getAvailableDevices())
.map(_.identity)
.flatten()
.value();
public getDevices(): IFuture<IDevice[]> {
return this.execute(() => this.devices, { canRunMainLoop: false });
}
private get deviceIdentifier(): string {
return options.device || XCode6Simulator.DEFAULT_DEVICE_IDENTIFIER;
public getSdks(): IFuture<ISdk[]> {
return this.execute(() => this.sdks, { canRunMainLoop: false });
}
private getAvailableDevices(): IDictionary<IDevice[]> {
if(_.isEmpty(this.availableDevices)) {
var deviceSet = $.classDefinition.getClassByName("SimDeviceSet")("defaultSet");
var devices = deviceSet("availableDevices");
var count = devices("count");
private get devices(): IDevice[] {
if(!this.cachedDevices) {
this.cachedDevices = [];
let deviceSet = $.classDefinition.getClassByName("SimDeviceSet")("defaultSet");
let devices = deviceSet("availableDevices");
let count = devices("count");
if(count > 0) {
for(var index=0; index<count; index++) {
var device = devices("objectAtIndex", index);
for(let index=0; index<count; index++) {
let device = devices("objectAtIndex", index);
var deviceIdentifier = device("deviceType")("identifier").toString();
var deviceIdentifierPrefixIndex = deviceIdentifier.indexOf(XCode6Simulator.DEVICE_IDENTIFIER_PREFIX);
var deviceIdentifierWithoutPrefix = deviceIdentifier.substring(deviceIdentifierPrefixIndex + XCode6Simulator.DEVICE_IDENTIFIER_PREFIX.length + 1);
let deviceIdentifier = device("deviceType")("identifier").toString();
let deviceIdentifierPrefixIndex = deviceIdentifier.indexOf(XCode6Simulator.DEVICE_IDENTIFIER_PREFIX);
let deviceIdentifierWithoutPrefix = deviceIdentifier.substring(deviceIdentifierPrefixIndex + XCode6Simulator.DEVICE_IDENTIFIER_PREFIX.length + 1);
var runtimeVersion = device("runtime")("versionString").toString();
let runtimeVersion = device("runtime")("versionString").toString();
if(!this.availableDevices[deviceIdentifier]) {
this.availableDevices[deviceIdentifier] = [];
}
this.availableDevices[deviceIdentifier].push({
device: device,
deviceIdentifier: deviceIdentifierWithoutPrefix,
fullDeviceIdentifier: this.buildFullDeviceIdentifier(deviceIdentifier),
runtimeVersion: runtimeVersion
this.cachedDevices.push({
name: deviceIdentifierWithoutPrefix,
id: deviceIdentifierWithoutPrefix,
fullId: this.buildFullDeviceIdentifier(deviceIdentifier),
runtimeVersion: runtimeVersion,
rawDevice: device
});

@@ -82,16 +71,52 @@ }

return this.availableDevices;
return this.cachedDevices;
}
private getDeviceByIdentifier(deviceIdentifier: string): any {
var availableDevices = this.getAvailableDevices();
if(!_.isEmpty(availableDevices)) {
var fullDeviceIdentifier = this.buildFullDeviceIdentifier(deviceIdentifier);
var selectedDevice = availableDevices[fullDeviceIdentifier];
if(selectedDevice) {
return selectedDevice[0].device;
private get sdks(): ISdk[] {
let systemRootClass = $.classDefinition.getClassByName("DTiPhoneSimulatorSystemRoot");
let roots = systemRootClass("knownRoots");
let count = roots("count");
let sdks: ISdk[] = [];
for(let index=0; index < count; index++) {
let root = roots("objectAtIndex", index);
let displayName = root("sdkDisplayName").toString();
let version = root("sdkVersion").toString();
let rootPath = root("sdkRootPath").toString();
sdks.push({ displayName, version, rootPath });
}
return sdks;
}
public sendNotification(notification: string): IFuture<void> {
let action = () => {
let device = this.getSimulatedDevice();
if (!device) {
errors.fail("Could not find device.");
}
let result = device("postDarwinNotification", $(notification), "error", null);
if (!result) {
errors.fail("Could not send notification: " + notification);
}
};
return this.execute(action, { canRunMainLoop: false });
}
private get deviceName(): string {
return options.device || XCode6Simulator.DEFAULT_DEVICE_IDENTIFIER;
}
private getDeviceByName(): IDevice {
let devices = this.getDevices().wait();
let device = _.find(devices, (device) => device.name === this.deviceName);
if(!device) {
errors.fail("Unable to find device with name ", this.deviceName);
}
errors.fail("Unable to find device with identifier ", deviceIdentifier);
return device;
}

@@ -98,0 +123,0 @@

///<reference path="./.d.ts"/>
"use strict";
var child_process = require("child_process");
var fs = require("fs");
var Future = require("fibers/future");
var os = require("os");
var path = require("path");
var util = require("util");
var errors = require("./errors");
var options = require("./options");
var utils = require("./utils");
var xcode = require("./xcode");
var xcode7SimulatorLib = require("./iphone-simulator-xcode-7");
var xcode6SimulatorLib = require("./iphone-simulator-xcode-6");

@@ -17,260 +14,72 @@ var xcode5SimulatorLib = require("./iphone-simulator-xcode-5");

function iPhoneSimulator() {
this.simulator = null;
this.simulator = this.createSimulator().wait();
}
iPhoneSimulator.prototype.run = function (appPath) {
if (!fs.existsSync(appPath)) {
errors.fail("Path does not exist ", appPath);
iPhoneSimulator.prototype.run = function (applicationPath, applicationIdentifier) {
if (!fs.existsSync(applicationPath)) {
errors.fail("Path does not exist ", applicationPath);
}
return this.execute(this.launch, { canRunMainLoop: true, appPath: appPath });
if (options.device) {
var deviceNames = _.unique(_.map(this.simulator.getDevices().wait(), function (device) { return device.name; }));
if (!_.contains(deviceNames, options.device)) {
errors.fail("Unable to find device " + options.device + ". The valid device names are " + deviceNames.join(", "));
}
}
if (options.sdkVersion) {
var runtimeVersions = _.unique(_.map(this.simulator.getDevices().wait(), function (device) { return device.runtimeVersion; }));
if (!_.contains(runtimeVersions, options.sdkVersion)) {
errors.fail("Unable to find sdk " + options.sdkVersion + ". The valid runtime versions are " + runtimeVersions.join(", "));
}
}
return this.simulator.run(applicationPath, applicationIdentifier);
};
iPhoneSimulator.prototype.printDeviceTypes = function () {
var _this = this;
var action = function () {
var simulator = _this.createSimulator();
_.each(simulator.deviceIdentifiersInfo, function (identifier) { return console.log(identifier); });
};
return this.execute(action, { canRunMainLoop: false });
return (function () {
var devices = _this.simulator.getDevices().wait();
_.each(devices, function (device) { return console.log("Device Identifier: " + device.fullId + ". " + os.EOL + "Runtime version: " + device.runtimeVersion + " " + os.EOL); });
}).future()();
};
iPhoneSimulator.prototype.printSDKS = function () {
var _this = this;
var action = function () {
var systemRootClass = _this.getClassByName("DTiPhoneSimulatorSystemRoot");
var roots = systemRootClass("knownRoots");
var count = roots("count");
var sdks = [];
for (var index = 0; index < count; index++) {
var root = roots("objectAtIndex", index);
var displayName = root("sdkDisplayName").toString();
var version = root("sdkVersion").toString();
var rootPath = root("sdkRootPath").toString();
sdks.push(new Sdk(displayName, version, rootPath));
}
sdks = _.sortBy(sdks, function (sdk) { return sdk.version; });
_.each(sdks, function (sdk) { return console.log(sdk.sdkInfo() + os.EOL); });
};
return this.execute(action, { canRunMainLoop: false });
return (function () {
var sdks = _this.simulator.getSdks().wait();
_.each(sdks, function (sdk) {
var output = " Display Name: " + sdk.displayName + " " + os.EOL + " Version: " + sdk.version + " " + os.EOL;
if (sdk.rootPath) {
output += " Root path: " + sdk.rootPath + " " + os.EOL;
}
console.log(output);
});
}).future()();
};
iPhoneSimulator.prototype.sendNotification = function (notification) {
if (!notification) {
errors.fail("Notification required");
errors.fail("Notification required.");
}
var action = function () {
var simulator = new xcode6SimulatorLib.XCode6Simulator();
var device = simulator.getSimulatedDevice();
if (!device) {
errors.fail("Could not find device");
}
var result = device("postDarwinNotification", $(notification), "error", null);
if (!result) {
errors.fail("Could not send notification: " + notification);
}
};
return this.execute(action, { canRunMainLoop: false });
return this.simulator.sendNotification(notification);
};
iPhoneSimulator.prototype.execute = function (action, opts) {
$.importFramework(iPhoneSimulator.FOUNDATION_FRAMEWORK_NAME);
$.importFramework(iPhoneSimulator.APPKIT_FRAMEWORK_NAME);
var pool = $.NSAutoreleasePool("alloc")("init");
var developerDirectoryPath = this.findDeveloperDirectory().wait();
if (!developerDirectoryPath) {
errors.fail("Unable to find developer directory");
}
this.loadFrameworks(developerDirectoryPath);
action.apply(this, [opts.appPath]);
var future = new Future();
if (opts.canRunMainLoop) {
// Keeps the Node loop running
(function runLoop() {
if ($.CFRunLoopRunInMode($.kCFRunLoopDefaultMode, 0.1, false)) {
setTimeout(runLoop, 0);
}
else {
pool("release");
future.return();
}
}());
}
else {
future.return();
}
return future;
};
iPhoneSimulator.prototype.launch = function (appPath) {
var sessionDelegate = $.NSObject.extend("DTiPhoneSimulatorSessionDelegate");
sessionDelegate.addMethod("session:didEndWithError:", "v@:@@", function (self, sel, sess, error) {
iPhoneSimulator.logSessionInfo(error, "Session ended without errors.", "Session ended with error ");
process.exit(0);
});
sessionDelegate.addMethod("session:didStart:withError:", "v@:@c@", function (self, sel, session, started, error) {
iPhoneSimulator.logSessionInfo(error, "Session started without errors.", "Session started with error ");
console.log(appPath + ": " + session("simulatedApplicationPID"));
if (options.exit) {
process.exit(0);
iPhoneSimulator.prototype.createSimulator = function () {
return (function () {
var xcodeVersionData = xcode.getXcodeVersionData().wait();
var majorVersion = xcodeVersionData.major;
var simulator = null;
if (majorVersion === "7") {
simulator = new xcode7SimulatorLib.XCode7Simulator();
}
});
sessionDelegate.register();
var appSpec = this.getClassByName("DTiPhoneSimulatorApplicationSpecifier")("specifierWithApplicationPath", $(appPath));
var config = this.getClassByName("DTiPhoneSimulatorSessionConfig")("alloc")("init")("autorelease");
config("setApplicationToSimulateOnStart", appSpec);
config("setSimulatedApplicationShouldWaitForDebugger", options.waitForDebugger);
var sdkRoot = options.sdkRoot ? $(options.sdkRoot) : this.getClassByName("DTiPhoneSimulatorSystemRoot")("defaultRoot");
config("setSimulatedSystemRoot", sdkRoot);
var simulator = this.createSimulator(config);
if (options.device) {
var validDeviceIdentifiers = simulator.validDeviceIdentifiers;
if (!_.contains(validDeviceIdentifiers, options.device)) {
errors.fail("Invalid device identifier %s. Valid device identifiers are %s.", options.device, utils.stringify(validDeviceIdentifiers));
else if (majorVersion === "6") {
simulator = new xcode6SimulatorLib.XCode6Simulator();
}
}
simulator.setSimulatedDevice(config);
if (options.logging) {
var logPath = this.createLogPipe(appPath).wait();
fs.createReadStream(logPath, { encoding: "utf8" }).pipe(process.stdout);
config("setSimulatedApplicationStdErrPath", $(logPath));
config("setSimulatedApplicationStdOutPath", $(logPath));
}
else {
if (options.stderr) {
config("setSimulatedApplicationStdErrPath", $(options.stderr));
else if (majorVersion === "5") {
simulator = new xcode5SimulatorLib.XCode5Simulator();
}
if (options.stdout) {
config("setSimulatedApplicationStdOutPath", $(options.stdout));
}
}
if (options.args) {
var args = options.args.trim().split(/\s+/);
var nsArgs = $.NSMutableArray("array");
args.forEach(function (x) { return nsArgs("addObject", $(x)); });
config("setSimulatedApplicationLaunchArgs", nsArgs);
}
config("setLocalizedClientName", $("ios-sim-portable"));
var sessionError = new Buffer("");
var timeoutParam = iPhoneSimulator.DEFAULT_TIMEOUT_IN_SECONDS;
if (options.timeout || options.timeout === 0) {
var parsedValue = parseInt(options.timeout);
if (!isNaN(parsedValue) && parsedValue > 0) {
timeoutParam = parsedValue;
}
else {
console.log(util.format("Specify the timeout in number of seconds to wait. It should be greater than 0. Default value %s seconds will be used.", iPhoneSimulator.DEFAULT_TIMEOUT_IN_SECONDS.toString()));
errors.fail("Unsupported xcode version " + xcodeVersionData.major + ".");
}
}
var time = $.NSNumber("numberWithDouble", timeoutParam);
var timeout = time("doubleValue");
var session = this.getClassByName("DTiPhoneSimulatorSession")("alloc")("init")("autorelease");
var delegate = sessionDelegate("alloc")("init");
session("setDelegate", delegate);
if (!session("requestStartWithConfig", config, "timeout", timeout, "error", sessionError)) {
errors.fail("Could not start simulator session ", sessionError);
}
return simulator;
}).future()();
};
iPhoneSimulator.prototype.loadFrameworks = function (developerDirectoryPath) {
this.loadFramework(path.join(developerDirectoryPath, iPhoneSimulator.DVT_FOUNDATION_RELATIVE_PATH));
this.loadFramework(path.join(developerDirectoryPath, iPhoneSimulator.DEV_TOOLS_FOUNDATION_RELATIVE_PATH));
if (fs.existsSync(path.join(developerDirectoryPath, iPhoneSimulator.CORE_SIMULATOR_RELATIVE_PATH))) {
this.loadFramework(path.join(developerDirectoryPath, iPhoneSimulator.CORE_SIMULATOR_RELATIVE_PATH));
}
var platformsError = null;
var dvtPlatformClass = this.getClassByName("DVTPlatform");
if (!dvtPlatformClass("loadAllPlatformsReturningError", platformsError)) {
errors.fail("Unable to loadAllPlatformsReturningError ", platformsError);
}
var simulatorFrameworkPath = path.join(developerDirectoryPath, iPhoneSimulator.SIMULATOR_FRAMEWORK_RELATIVE_PATH_LEGACY);
if (!fs.existsSync(simulatorFrameworkPath)) {
simulatorFrameworkPath = path.join(developerDirectoryPath, iPhoneSimulator.SIMULATOR_FRAMEWORK_RELATIVE_PATH);
}
this.loadFramework(simulatorFrameworkPath);
};
iPhoneSimulator.prototype.loadFramework = function (frameworkPath) {
var bundle = $.NSBundle("bundleWithPath", $(frameworkPath));
if (!bundle("load")) {
errors.fail("Unable to load ", frameworkPath);
}
};
iPhoneSimulator.prototype.findDeveloperDirectory = function () {
var future = new Future();
var capturedOut = "";
var capturedErr = "";
var childProcess = child_process.spawn("xcode-select", ["-print-path"]);
if (childProcess.stdout) {
childProcess.stdout.on("data", function (data) {
capturedOut += data;
});
}
if (childProcess.stderr) {
childProcess.stderr.on("data", function (data) {
capturedErr += data;
});
}
childProcess.on("close", function (arg) {
var exitCode = typeof arg == 'number' ? arg : arg && arg.code;
if (exitCode === 0) {
future.return(capturedOut ? capturedOut.trim() : null);
}
else {
future.throw(util.format("Command xcode-select -print-path failed with exit code %s. Error output: \n %s", exitCode, capturedErr));
}
});
return future;
};
iPhoneSimulator.prototype.getClassByName = function (className) {
return $.classDefinition.getClassByName(className);
};
iPhoneSimulator.logSessionInfo = function (error, successfulMessage, errorMessage) {
if (error) {
console.log(util.format("%s %s", errorMessage, error));
process.exit(1);
}
console.log(successfulMessage);
};
iPhoneSimulator.prototype.createSimulator = function (config) {
if (!config) {
config = this.getClassByName("DTiPhoneSimulatorSessionConfig")("alloc")("init")("autorelease");
}
var simulator;
if (_.contains(config.methods(), "setDevice:")) {
simulator = new xcode6SimulatorLib.XCode6Simulator();
}
else {
simulator = new xcode5SimulatorLib.XCode5Simulator();
}
return simulator;
};
iPhoneSimulator.prototype.createLogPipe = function (appPath) {
var future = new Future();
var logPath = path.join(path.dirname(appPath), "." + path.basename(appPath, ".app") + ".log");
var command = util.format("rm -f \"%s\" && mkfifo \"%s\"", logPath, logPath);
child_process.exec(command, function (error, stdout, stderr) {
if (error) {
future.throw(error);
}
else {
future.return(logPath);
}
});
return future;
};
iPhoneSimulator.FOUNDATION_FRAMEWORK_NAME = "Foundation";
iPhoneSimulator.APPKIT_FRAMEWORK_NAME = "AppKit";
iPhoneSimulator.DVT_FOUNDATION_RELATIVE_PATH = "../SharedFrameworks/DVTFoundation.framework";
iPhoneSimulator.DEV_TOOLS_FOUNDATION_RELATIVE_PATH = "../OtherFrameworks/DevToolsFoundation.framework";
iPhoneSimulator.CORE_SIMULATOR_RELATIVE_PATH = "Library/PrivateFrameworks/CoreSimulator.framework";
iPhoneSimulator.SIMULATOR_FRAMEWORK_RELATIVE_PATH_LEGACY = "Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/DVTiPhoneSimulatorRemoteClient.framework";
iPhoneSimulator.SIMULATOR_FRAMEWORK_RELATIVE_PATH = "../SharedFrameworks/DVTiPhoneSimulatorRemoteClient.framework";
iPhoneSimulator.DEFAULT_TIMEOUT_IN_SECONDS = 90;
return iPhoneSimulator;
})();
exports.iPhoneSimulator = iPhoneSimulator;
var Sdk = (function () {
function Sdk(displayName, version, rootPath) {
this.displayName = displayName;
this.version = version;
this.rootPath = rootPath;
}
Sdk.prototype.sdkInfo = function () {
return [util.format(" Display Name: %s", this.displayName),
util.format(" Version: %s", this.version),
util.format(" Root path: %s", this.rootPath)].join(os.EOL);
};
return Sdk;
})();
//# sourceMappingURL=iphone-simulator.js.map

@@ -13,3 +13,5 @@ ///<reference path="./.d.ts"/>

import options = require("./options");
import utils = require("./utils");
import xcode = require("./xcode");
import xcode7SimulatorLib = require("./iphone-simulator-xcode-7");
import xcode6SimulatorLib = require("./iphone-simulator-xcode-6");

@@ -21,303 +23,79 @@ import xcode5SimulatorLib = require("./iphone-simulator-xcode-5");

export class iPhoneSimulator implements IiPhoneSimulator {
private simulator: ISimulator = null;
private static FOUNDATION_FRAMEWORK_NAME = "Foundation";
private static APPKIT_FRAMEWORK_NAME = "AppKit";
private static DVT_FOUNDATION_RELATIVE_PATH = "../SharedFrameworks/DVTFoundation.framework";
private static DEV_TOOLS_FOUNDATION_RELATIVE_PATH = "../OtherFrameworks/DevToolsFoundation.framework";
private static CORE_SIMULATOR_RELATIVE_PATH = "Library/PrivateFrameworks/CoreSimulator.framework";
private static SIMULATOR_FRAMEWORK_RELATIVE_PATH_LEGACY = "Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/DVTiPhoneSimulatorRemoteClient.framework";
private static SIMULATOR_FRAMEWORK_RELATIVE_PATH = "../SharedFrameworks/DVTiPhoneSimulatorRemoteClient.framework";
private static DEFAULT_TIMEOUT_IN_SECONDS = 90;
public run(appPath: string): IFuture<void> {
if(!fs.existsSync(appPath)) {
errors.fail("Path does not exist ", appPath);
}
return this.execute(this.launch, { canRunMainLoop: true, appPath: appPath });
constructor() {
this.simulator = this.createSimulator().wait();
}
public printDeviceTypes(): IFuture<void> {
var action = () => {
var simulator = this.createSimulator();
_.each(simulator.deviceIdentifiersInfo, (identifier: any) => console.log(identifier));
};
return this.execute(action, { canRunMainLoop: false });
}
public printSDKS(): IFuture<void> {
var action = () => {
var systemRootClass = this.getClassByName("DTiPhoneSimulatorSystemRoot");
var roots = systemRootClass("knownRoots");
var count = roots("count");
var sdks: ISdk[] = [];
for(var index=0; index < count; index++) {
var root = roots("objectAtIndex", index);
var displayName = root("sdkDisplayName").toString();
var version = root("sdkVersion").toString();
var rootPath = root("sdkRootPath").toString();
sdks.push(new Sdk(displayName, version, rootPath));
}
sdks = _.sortBy(sdks, (sdk: ISdk) => sdk.version);
_.each(sdks, (sdk: ISdk) => console.log(sdk.sdkInfo() + os.EOL));
};
return this.execute(action, { canRunMainLoop: false });
}
public sendNotification(notification: string): IFuture<void> {
if(!notification) {
errors.fail("Notification required");
public run(applicationPath: string, applicationIdentifier: string): IFuture<void> {
if(!fs.existsSync(applicationPath)) {
errors.fail("Path does not exist ", applicationPath);
}
var action = () => {
var simulator = new xcode6SimulatorLib.XCode6Simulator();
var device = simulator.getSimulatedDevice();
if (!device) {
errors.fail("Could not find device");
}
var result = device("postDarwinNotification", $(notification), "error", null);
if (!result) {
errors.fail("Could not send notification: " + notification);
}
};
return this.execute(action, { canRunMainLoop: false });
}
private execute(action: (appPath?: string) => any, opts: IExecuteOptions): IFuture<void> {
$.importFramework(iPhoneSimulator.FOUNDATION_FRAMEWORK_NAME);
$.importFramework(iPhoneSimulator.APPKIT_FRAMEWORK_NAME);
var pool = $.NSAutoreleasePool("alloc")("init");
var developerDirectoryPath = this.findDeveloperDirectory().wait();
if(!developerDirectoryPath) {
errors.fail("Unable to find developer directory");
}
this.loadFrameworks(developerDirectoryPath);
action.apply(this, [opts.appPath]);
var future = new Future<void>();
if(opts.canRunMainLoop) {
// Keeps the Node loop running
(function runLoop() {
if($.CFRunLoopRunInMode($.kCFRunLoopDefaultMode, 0.1, false)) {
setTimeout(runLoop, 0);
} else {
pool("release");
future.return();
}
}());
} else {
future.return();
}
return future;
}
private launch(appPath: string): void {
var sessionDelegate = $.NSObject.extend("DTiPhoneSimulatorSessionDelegate");
sessionDelegate.addMethod("session:didEndWithError:", "v@:@@", function(self: any, sel: any, sess: any, error: any) {
iPhoneSimulator.logSessionInfo(error, "Session ended without errors.", "Session ended with error ");
process.exit(0);
});
sessionDelegate.addMethod("session:didStart:withError:", "v@:@c@", function(self: any, sel: string, session: any, started: boolean, error:any) {
iPhoneSimulator.logSessionInfo(error, "Session started without errors.", "Session started with error ");
console.log(`${appPath}: ${session("simulatedApplicationPID")}`);
if(options.exit) {
process.exit(0);
}
});
sessionDelegate.register();
var appSpec = this.getClassByName("DTiPhoneSimulatorApplicationSpecifier")("specifierWithApplicationPath", $(appPath));
var config = this.getClassByName("DTiPhoneSimulatorSessionConfig")("alloc")("init")("autorelease");
config("setApplicationToSimulateOnStart", appSpec);
config("setSimulatedApplicationShouldWaitForDebugger", options.waitForDebugger);
var sdkRoot = options.sdkRoot ? $(options.sdkRoot) : this.getClassByName("DTiPhoneSimulatorSystemRoot")("defaultRoot");
config("setSimulatedSystemRoot", sdkRoot);
var simulator = this.createSimulator(config);
if(options.device) {
var validDeviceIdentifiers = simulator.validDeviceIdentifiers;
if(!_.contains(validDeviceIdentifiers, options.device)) {
errors.fail("Invalid device identifier %s. Valid device identifiers are %s.", options.device, utils.stringify(validDeviceIdentifiers));
let deviceNames = _.unique(_.map(this.simulator.getDevices().wait(), (device: IDevice) => device.name));
if(!_.contains(deviceNames, options.device)) {
errors.fail(`Unable to find device ${options.device}. The valid device names are ${deviceNames.join(", ")}`);
}
}
simulator.setSimulatedDevice(config);
if(options.logging) {
var logPath = this.createLogPipe(appPath).wait();
fs.createReadStream(logPath, { encoding: "utf8" }).pipe(process.stdout);
config("setSimulatedApplicationStdErrPath", $(logPath));
config("setSimulatedApplicationStdOutPath", $(logPath));
} else {
if(options.stderr) {
config("setSimulatedApplicationStdErrPath", $(options.stderr));
if(options.sdkVersion) {
let runtimeVersions = _.unique(_.map(this.simulator.getDevices().wait(), (device: IDevice) => device.runtimeVersion));
if(!_.contains(runtimeVersions, options.sdkVersion)) {
errors.fail(`Unable to find sdk ${options.sdkVersion}. The valid runtime versions are ${runtimeVersions.join(", ")}`);
}
if(options.stdout) {
config("setSimulatedApplicationStdOutPath", $(options.stdout));
}
}
if (options.args) {
var args = options.args.trim().split(/\s+/);
var nsArgs = $.NSMutableArray("array");
args.forEach((x: string) => nsArgs("addObject", $(x)));
config("setSimulatedApplicationLaunchArgs", nsArgs);
}
config("setLocalizedClientName", $("ios-sim-portable"));
var sessionError: any = new Buffer("");
var timeoutParam = iPhoneSimulator.DEFAULT_TIMEOUT_IN_SECONDS;
if (options.timeout || options.timeout === 0) {
var parsedValue = parseInt(options.timeout);
if(!isNaN(parsedValue) && parsedValue > 0) {
timeoutParam = parsedValue;
}
else {
console.log(util.format("Specify the timeout in number of seconds to wait. It should be greater than 0. Default value %s seconds will be used.", iPhoneSimulator.DEFAULT_TIMEOUT_IN_SECONDS.toString()));
}
}
var time = $.NSNumber("numberWithDouble", timeoutParam);
var timeout = time("doubleValue");
var session = this.getClassByName("DTiPhoneSimulatorSession")("alloc")("init")("autorelease");
var delegate = sessionDelegate("alloc")("init");
session("setDelegate", delegate);
if(!session("requestStartWithConfig", config, "timeout", timeout, "error", sessionError)) {
errors.fail("Could not start simulator session ", sessionError);
}
return this.simulator.run(applicationPath, applicationIdentifier);
}
private loadFrameworks(developerDirectoryPath: string): void {
this.loadFramework(path.join(developerDirectoryPath, iPhoneSimulator.DVT_FOUNDATION_RELATIVE_PATH));
this.loadFramework(path.join(developerDirectoryPath, iPhoneSimulator.DEV_TOOLS_FOUNDATION_RELATIVE_PATH));
if(fs.existsSync(path.join(developerDirectoryPath, iPhoneSimulator.CORE_SIMULATOR_RELATIVE_PATH))) {
this.loadFramework(path.join(developerDirectoryPath, iPhoneSimulator.CORE_SIMULATOR_RELATIVE_PATH));
}
var platformsError: string = null;
var dvtPlatformClass = this.getClassByName("DVTPlatform");
if(!dvtPlatformClass("loadAllPlatformsReturningError", platformsError)) {
errors.fail("Unable to loadAllPlatformsReturningError ", platformsError);
}
var simulatorFrameworkPath = path.join(developerDirectoryPath, iPhoneSimulator.SIMULATOR_FRAMEWORK_RELATIVE_PATH_LEGACY);
if(!fs.existsSync(simulatorFrameworkPath)) {
simulatorFrameworkPath = path.join(developerDirectoryPath, iPhoneSimulator.SIMULATOR_FRAMEWORK_RELATIVE_PATH);
}
this.loadFramework(simulatorFrameworkPath);
public printDeviceTypes(): IFuture<void> {
return (() => {
let devices = this.simulator.getDevices().wait();
_.each(devices, device => console.log(`Device Identifier: ${device.fullId}. ${os.EOL}Runtime version: ${device.runtimeVersion} ${os.EOL}`));
}).future<void>()();
}
private loadFramework(frameworkPath: string) {
var bundle = $.NSBundle("bundleWithPath", $(frameworkPath));
if(!bundle("load")) {
errors.fail("Unable to load ", frameworkPath);
}
}
private findDeveloperDirectory(): IFuture<string> {
var future = new Future<string>();
var capturedOut = "";
var capturedErr = "";
var childProcess = child_process.spawn("xcode-select", ["-print-path"]);
if(childProcess.stdout) {
childProcess.stdout.on("data", (data: string) => {
capturedOut += data;
public printSDKS(): IFuture<void> {
return (() => {
let sdks = this.simulator.getSdks().wait();
_.each(sdks, (sdk) => {
let output = ` Display Name: ${sdk.displayName} ${os.EOL} Version: ${sdk.version} ${os.EOL}`;
if(sdk.rootPath) {
output += ` Root path: ${sdk.rootPath} ${os.EOL}`;
}
console.log(output);
});
}
if(childProcess.stderr) {
childProcess.stderr.on("data", (data: string) => {
capturedErr += data;
});
}
childProcess.on("close", (arg: any) => {
var exitCode = typeof arg == 'number' ? arg : arg && arg.code;
if(exitCode === 0) {
future.return(capturedOut ? capturedOut.trim() : null);
} else {
future.throw(util.format("Command xcode-select -print-path failed with exit code %s. Error output: \n %s", exitCode, capturedErr));
}
});
return future;
}).future<void>()();
}
private getClassByName(className: string): any {
return $.classDefinition.getClassByName(className);
}
private static logSessionInfo(error: any, successfulMessage: string, errorMessage: string): void {
if(error) {
console.log(util.format("%s %s", errorMessage, error));
process.exit(1);
public sendNotification(notification: string): IFuture<void> {
if(!notification) {
errors.fail("Notification required.");
}
console.log(successfulMessage);
return this.simulator.sendNotification(notification);
}
private createSimulator(config?: any): ISimulator {
if(!config) {
config = this.getClassByName("DTiPhoneSimulatorSessionConfig")("alloc")("init")("autorelease");
}
private createSimulator(): IFuture<ISimulator> {
return (() => {
let xcodeVersionData = xcode.getXcodeVersionData().wait();
let majorVersion = xcodeVersionData.major;
var simulator: ISimulator;
if(_.contains(config.methods(), "setDevice:")) {
simulator = new xcode6SimulatorLib.XCode6Simulator();
} else {
simulator = new xcode5SimulatorLib.XCode5Simulator();
}
let simulator: ISimulator = null;
return simulator;
}
private createLogPipe(appPath: string): IFuture<string> {
var future = new Future<string>();
var logPath = path.join(path.dirname(appPath), "." + path.basename(appPath, ".app") + ".log");
var command = util.format("rm -f \"%s\" && mkfifo \"%s\"", logPath, logPath);
child_process.exec(command, (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) => {
if(error) {
future.throw(error);
if(majorVersion === "7") {
simulator = new xcode7SimulatorLib.XCode7Simulator();
} else if (majorVersion === "6") {
simulator = new xcode6SimulatorLib.XCode6Simulator();
} else if(majorVersion === "5") {
simulator = new xcode5SimulatorLib.XCode5Simulator();
} else {
future.return(logPath);
errors.fail(`Unsupported xcode version ${xcodeVersionData.major}.`);
}
});
return future;
return simulator;
}).future<ISimulator>()();
}
}
class Sdk implements ISdk {
constructor(public displayName: string,
public version: string,
public rootPath: string) { }
public sdkInfo(): string {
return [util.format(" Display Name: %s", this.displayName),
util.format(" Version: %s", this.version),
util.format(" Root path: %s", this.rootPath)].join(os.EOL);
}
}
///<reference path=".d.ts"/>
"use strict";
var yargs = require("yargs");
var OptionType = (function () {
function OptionType() {
}
OptionType.String = "string";
OptionType.Boolean = "boolean";
return OptionType;
})();
var knownOptions = {
"debug": Boolean,
"exit": Boolean,
"device": String,
"stdout": String,
"stderr": String,
"env": String,
"args": String,
"timeout": String,
"help": Boolean,
"logging": Boolean,
"waitForDebugger": Boolean
"debug": { type: OptionType.Boolean },
"exit": { type: OptionType.Boolean },
"device": { type: OptionType.String },
"stdout": { type: OptionType.String },
"stderr": { type: OptionType.String },
"env": { type: OptionType.String },
"args": { type: OptionType.String },
"timeout": { type: OptionType.String },
"help": { type: OptionType.Boolean },
"logging": { type: OptionType.Boolean },
"waitForDebugger": { type: OptionType.Boolean },
"sdkVersion": { type: OptionType.String }
};
var parsed = {};
_.each(_.keys(knownOptions), function (opt) {
var type = knownOptions[opt];
if (type === String) {
yargs.string(opt);
}
else if (type === Boolean) {
yargs.boolean(opt);
}
var argv = yargs(process.argv.slice(2)).options(knownOptions).argv;
// DO NOT REMOVE { } as when they are missing and some of the option values is false, the each stops as it thinks we have set "return false".
_.each(_.keys(argv), function (optionName) {
parsed[optionName] = argv[optionName];
});
_.each(_.keys(yargs.argv), function (opt) { return parsed[opt] = yargs.argv[opt]; });
module.exports = parsed;
//# sourceMappingURL=options.js.map

@@ -6,29 +6,30 @@ ///<reference path=".d.ts"/>

class OptionType {
public static String = "string";
public static Boolean = "boolean";
}
var knownOptions: any = {
"debug": Boolean,
"exit": Boolean,
"device": String,
"stdout": String,
"stderr": String,
"env": String,
"args": String,
"timeout": String,
"help": Boolean,
"logging": Boolean,
"waitForDebugger": Boolean
"debug": { type: OptionType.Boolean },
"exit": { type: OptionType.Boolean },
"device": { type: OptionType.String },
"stdout": { type: OptionType.String },
"stderr": { type: OptionType.String },
"env": { type: OptionType.String },
"args": { type: OptionType.String },
"timeout": { type: OptionType.String },
"help": { type: OptionType.Boolean },
"logging": { type: OptionType.Boolean },
"waitForDebugger": { type: OptionType.Boolean },
"sdkVersion": { type: OptionType.String }
};
var parsed: any = {};
var argv = yargs(process.argv.slice(2)).options(knownOptions).argv;
_.each(_.keys(knownOptions), opt => {
var type = knownOptions[opt];
if(type === String) {
yargs.string(opt);
} else if (type === Boolean) {
yargs.boolean(opt);
}
// DO NOT REMOVE { } as when they are missing and some of the option values is false, the each stops as it thinks we have set "return false".
_.each(_.keys(argv), optionName => {
parsed[optionName] = argv[optionName]
});
_.each(_.keys(yargs.argv), opt => parsed[opt] = yargs.argv[opt]);
export = parsed;

@@ -0,1 +1,4 @@

///<reference path="./.d.ts"/>
"use strict";
var Fiber = require("fibers");
function stringify(arr, delimiter) {

@@ -6,2 +9,8 @@ delimiter = delimiter || ", ";

exports.stringify = stringify;
function sleep(ms) {
var fiber = Fiber.current;
setTimeout(function () { return fiber.run(); }, ms);
Fiber.yield();
}
exports.sleep = sleep;
//# sourceMappingURL=utils.js.map

@@ -0,4 +1,15 @@

///<reference path="./.d.ts"/>
"use strict";
import * as Fiber from "fibers";
export function stringify(arr: string[], delimiter?: string): string {
delimiter = delimiter || ", ";
return arr.join(delimiter);
}
export function sleep(ms: number): void {
let fiber = Fiber.current;
setTimeout(() => fiber.run(), ms);
Fiber.yield();
}
{
"name": "ios-sim-portable",
"version": "1.0.10-beta",
"version": "1.0.11-beta",
"description": "",

@@ -33,3 +33,3 @@ "main": "./lib/ios-sim.js",

"nodobjc": "https://github.com/telerik/NodObjC/tarball/v2.0.0.0",
"yargs": "1.2.2"
"yargs": "3.15.0"
},

@@ -39,7 +39,8 @@ "devDependencies": {

"grunt": "0.4.5",
"grunt-ts": "4.2.0"
"grunt-ts": "4.2.0",
"typescript": "1.6.2"
},
"engines": {
"node": ">=0.10.26 <0.10.34 || >=0.10.35"
"node": ">=0.10.40 <0.11.0 || >=0.12.8 <0.13.0 || >=4.2.1"
}
}

@@ -0,0 +0,0 @@ var fs = require("fs");

@@ -0,0 +0,0 @@ ios-sim-portable

@@ -0,0 +0,0 @@ --[]--

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc