appium-ios-simulator
Version:
iOS Simulator interface for Appium.
82 lines • 3.37 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSimulator = getSimulator;
const simulator_xcode_14_1 = require("./simulator-xcode-14");
const simulator_xcode_15_1 = require("./simulator-xcode-15");
const utils_1 = require("./utils");
const xcode = __importStar(require("appium-xcode"));
const logger_1 = require("./logger");
/**
* Finds and returns the corresponding Simulator instance for the given ID.
*
* @param udid - The ID of an existing Simulator.
* @param opts - Simulator lookup options
* @throws {Error} If the Simulator with given udid does not exist in devices list.
* If you want to create a new simulator, you can use the `createDevice()` method of
* [node-simctl](github.com/appium/node-simctl).
* @return Simulator object associated with the udid passed in.
*/
async function getSimulator(udid, opts = {}) {
let platform = opts.platform ?? 'iOS';
const { checkExistence = true, devicesSetPath, logger, } = opts;
const xcodeVersion = (0, utils_1.assertXcodeVersion)(await xcode.getVersion(true));
if (checkExistence) {
const simulatorInfo = await (0, utils_1.getSimulatorInfo)(udid, {
devicesSetPath
});
if (!simulatorInfo) {
throw new Error(`No sim found with udid '${udid}'`);
}
platform = simulatorInfo.platform;
}
(logger ?? logger_1.log).info(`Constructing ${platform} simulator for Xcode version ${xcodeVersion.versionString} with udid '${udid}'`);
let SimClass;
switch (xcodeVersion.major) {
case utils_1.MIN_SUPPORTED_XCODE_VERSION:
SimClass = simulator_xcode_14_1.SimulatorXcode14;
break;
case 15:
default:
SimClass = simulator_xcode_15_1.SimulatorXcode15;
break;
}
const result = new SimClass(udid, xcodeVersion, logger);
if (devicesSetPath) {
result.devicesSetPath = devicesSetPath;
}
return result;
}
//# sourceMappingURL=simulator.js.map