diff --git a/CHANGELOG.md b/CHANGELOG.md index b7575893c..8281368f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [7.5.5](https://github.com/appium/appium-xcuitest-driver/compare/v7.5.4...v7.5.5) (2024-03-26) + + +### Miscellaneous Chores + +* add launchApp via devicectl ([#2354](https://github.com/appium/appium-xcuitest-driver/issues/2354)) ([3907455](https://github.com/appium/appium-xcuitest-driver/commit/3907455d84519709e07d683ac26ef2047ede9d59)) + ## [7.5.4](https://github.com/appium/appium-xcuitest-driver/compare/v7.5.3...v7.5.4) (2024-03-25) diff --git a/lib/devicectl.js b/lib/devicectl.js index 0a61a62ac..9104604b5 100644 --- a/lib/devicectl.js +++ b/lib/devicectl.js @@ -81,6 +81,14 @@ const XCRUN = 'xcrun'; * @property {number} [timeout=120000] The timeout for pulling a file in milliseconds. */ + +/** + * An option for launchApp method by devicectl. + * @typedef {Object} LaunchAppOptions + * @property {import('@appium/types').StringRecord} [env] Bundle id to Environment variables for the launching app process. + * @property {boolean} [terminateExisting=false] Whether terminating the already running app. + */ + export class Devicectl { /** * @since Xcode 15, iOS 17 @@ -246,4 +254,31 @@ export class Devicectl { }); return JSON.parse(stdout).result.apps; } + + /** + * Launch the given bundle id application with the given environment variable. + * This method is over devicectl command, this it may take additional seconds to launch the app. + * Please use via WDA or via appium-ios-device as primary method to launch app if possible. + * + * @param {string} bundleId Bundle id to launch. + * @param {LaunchAppOptions} opts launching app with devicectl command options. + * @returns {Promise} + * @throws {Error} If the launching app command fails. For example, the given bundle id did not exist. + */ + async launchApp(bundleId, opts) { + const { + env, + terminateExisting = false + } = opts; + + const subcommandOptions = [bundleId]; + if (terminateExisting) { + subcommandOptions.push('--terminate-existing'); + }; + if (!_.isEmpty(env)) { + subcommandOptions.push('--environment-variables', JSON.stringify(_.mapValues(env, (v) => _.toString(v)))); + }; + + await this.execute(['device', 'process', 'launch'], { subcommandOptions, asJson: false}); + } } diff --git a/package.json b/package.json index da4e790da..14a8b0037 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "xcuitest", "xctest" ], - "version": "7.5.4", + "version": "7.5.5", "author": "Appium Contributors", "license": "Apache-2.0", "repository": { @@ -81,7 +81,7 @@ "appium-ios-device": "^2.5.4", "appium-ios-simulator": "^5.5.1", "appium-remote-debugger": "^11.0.0", - "appium-webdriveragent": "^7.3.0", + "appium-webdriveragent": "^8.0.1", "appium-xcode": "^5.1.4", "async-lock": "^1.4.0", "asyncbox": "^3.0.0",