Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: terminateApp with devicectl for iOS 17 #1997

Merged
merged 11 commits into from
Sep 19, 2023
Prev Previous commit
Next Next commit
chore: add comment further
  • Loading branch information
KazuCocoa committed Sep 17, 2023
commit e17732eb150a03bc65f7a9c1e1ec57b89c6fbee4
19 changes: 12 additions & 7 deletions lib/ios-deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {fs, timing} from 'appium/support';
import {fs, timing, util} from 'appium/support';
import path from 'path';
import {services, utilities, INSTRUMENT_CHANNEL} from 'appium-ios-device';
import B from 'bluebird';
Expand Down Expand Up @@ -206,10 +206,13 @@ class IOSDeploy {
const executableName = apps[bundleId].CFBundleExecutable;
log.debug(`The executable name for the bundle id '${bundleId}' was '${executableName}'`);

log.info(`platformVersion: '${platformVersion}'`);
// 'devicectl' has overhead than the instrument service via appium-ios-device,
// so hre uses the 'devicectl' only for iOS 17+.
if (util.compareVersions(platformVersion, '>', '17.0')) {
log.debug(`Calling devicectl to kill the process`);
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved

// FIXME: replace `devicectl` command with a wrapper later

KazuCocoa marked this conversation as resolved.
Show resolved Hide resolved
// TODO: use version comparison
if (platformVersion === '17.0') {
const xcrunBinnaryPath = await requireXcrun();
let args = [];
args.push(
Expand All @@ -219,8 +222,10 @@ class IOSDeploy {
'processes',
`--device`, this.udid
);
const {stdout} = await exec(xcrunBinnaryPath, args, { timeout: 60 * 1000 });
// e.g.
const {stdout} = await exec(xcrunBinnaryPath, args);
// Each line has spaces. devicectl has JSON output option, but it writes it to a file only.
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
// Here parse the standard output directly.
// e.g.:
// 823 /private/var/containers/Bundle/Application/8E748312-8CBE-4C13-8295-C2EF3ED2C0C1/WebDriverAgentRunner-Runner.app/WebDriverAgentRunner-Runner
// 824 /Applications/MobileSafari.app/MobileSafari
// 825 /usr/libexec/debugserver
Expand All @@ -236,7 +241,7 @@ class IOSDeploy {
'-p', `${executableLine?.split(/\s+/)[0]}`,
`--device`, this.udid
);
await exec(xcrunBinnaryPath, args, { timeout: 60 * 1000 });
await exec(xcrunBinnaryPath, args);
} else {
instrumentService = await services.startInstrumentService(this.udid);
const processes = await instrumentService.callChannel(
Expand Down
Loading