Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/real-device-management.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';
import {buildSafariPreferences} from './app-utils';
import {utilities} from 'appium-ios-device';
import { getConnectedDevices } from './real-device';

const DEFAULT_APP_INSTALLATION_TIMEOUT_MS = 8 * 60 * 1000;

Expand Down Expand Up @@ -114,11 +114,11 @@ export function applySafariStartupArgs() {
*/
export async function detectUdid() {
this.log.debug('Auto-detecting real device udid...');
const udids = await utilities.getConnectedDevices();
const udids = await getConnectedDevices();
if (_.isEmpty(udids)) {
throw new Error('No real devices are connected to the host');
}
const udid = _.last(udids);
const udid = udids[udids.length - 1];
if (udids.length > 1) {
this.log.info(`Multiple devices found: ${udids.join(', ')}`);
this.log.info(`Choosing '${udid}'. Consider settings the 'udid' capability if another device must be selected`);
Expand Down
17 changes: 16 additions & 1 deletion lib/real-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ const INSTALLATION_STAGING_DIR = 'PublicStaging';
* @returns {Promise<string[]>}
*/
export async function getConnectedDevices() {
return await utilities.getConnectedDevices();
Copy link
Member

@KazuCocoa KazuCocoa Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The devicectl command could have a situation that doesn't work or conflict if the same env has core device service injected (e.g. 3rd party tools) So, this could be a breaking change for such a condition.

Currently, this may help only for tvOS (and env which doesn't expose usbmuxd for wifi-connected devices), thus maybe it makes sense to add a new capability to use devicectl prior to appium-ios-device

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the logic to use an env flag instead. I do't want to introduce a new capability as I expect this solution to be temporary until we fully ditch appium-ios-device and switch to appium-ios-remotexpc usage

const listDevicesViaIosDevice = async () => await utilities.getConnectedDevices();
const listDevicesViaDevicectl = async () => (await new Devicectl('').listDevices())
.map(({hardwareProperties}) => hardwareProperties?.udid)
.filter(Boolean);

const [resIosDevice, resDevicectl] = await Promise.allSettled([
listDevicesViaIosDevice(),
listDevicesViaDevicectl()
]);
if (resDevicectl.status === 'fulfilled') {
return resDevicectl.value;
}
if (resIosDevice.status === 'fulfilled') {
return resIosDevice.value;
}
throw resIosDevice.reason;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"lru-cache": "^11.1.0",
"moment": "^2.29.4",
"moment-timezone": "^0.x",
"node-devicectl": "^1.0.1",
"node-devicectl": "^1.1.0",
"node-simctl": "^8.0.0",
"portscanner": "^2.2.0",
"semver": "^7.5.4",
Expand Down
Loading