Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion docs/reference/execute-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,11 @@ Offload applications will not be in the result.
Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
applicationType | string | no | The type of applications to list. Either `System` or `User` (the default one) | System
returnAttributes | array<string> | no | Array of attribute names to return for each app. If not provided, all available attributes are returned. Common attributes include: `CFBundleIdentifier`, `CFBundleName`, `CFBundleDisplayName`, `CFBundleVersion`, `CFBundleShortVersionString`, `UIFileSharingEnabled` | `['CFBundleIdentifier', 'CFBundleName', 'CFBundleVersion']`

#### Returned Result

A map where keys are bundle identifiers and values are maps of platform-specific app properties. Having `UIFileSharingEnabled` set to `true` in the app properties map means this app supports file upload and download into its `documents` container. Read the [File Transfer](../guides/file-transfer.md) guide for more details.
A map where keys are bundle identifiers and values are maps of platform-specific app properties. The properties included depend on the `returnAttributes` parameter. Having `UIFileSharingEnabled` set to `true` in the app properties map means this app supports file upload and download into its `documents` container. Read the [File Transfer](../guides/file-transfer.md) guide for more details.

### mobile: clearApp

Expand Down
7 changes: 5 additions & 2 deletions lib/commands/app-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,23 @@ export async function queryAppState(
* List applications installed on the real device under test
*
* Read [Pushing/Pulling files](https://appium.io/docs/en/writing-running-appium/ios/ios-xctest-file-movement/) for more details.
* @param applicationType - The type of applications to list.
* @param applicationType - The type of applications to list (default: 'User').
* @param returnAttributes - Array of attribute names to return for each app (e.g., ["CFBundleIdentifier", "CFBundleName"]).
* If not provided, all available attributes are returned.
* @returns An object mapping bundle identifiers to app properties (e.g., CFBundleName, CFBundleVersion, etc.).
* @remarks Having `UIFileSharingEnabled` set to `true` in the app properties means the app supports file upload/download in its `documents` container.
* @group Real Device Only
*/
export async function mobileListApps(
this: XCUITestDriver,
applicationType: 'User' | 'System' = 'User',
returnAttributes?: string[],
): Promise<AppInfoMapping> {
const device = requireRealDevice(this, 'Listing apps');
const useRemoteXPC = isIos18OrNewer(this.opts);
const client = await InstallationProxyClient.create(device.udid, useRemoteXPC);
try {
return await client.listApplications({applicationType});
return await client.listApplications({applicationType, returnAttributes});
} finally {
await client.close();
}
Expand Down
16 changes: 13 additions & 3 deletions lib/device/installation-proxy-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,25 @@ export class InstallationProxyClient {
* @returns Object keyed by bundle ID
*/
async listApplications(opts?: ListApplicationOptions): Promise<AppInfoMapping> {
let normalizedOpts = opts;

// Ensure CFBundleIdentifier is always included
if (opts?.returnAttributes && !opts.returnAttributes.includes('CFBundleIdentifier')) {
normalizedOpts = {
...opts,
returnAttributes: ['CFBundleIdentifier', ...opts.returnAttributes],
};
}

if (!this.isRemoteXPC) {
return await this.iosDeviceService.listApplications(opts);
return await this.iosDeviceService.listApplications(normalizedOpts);
}

// RemoteXPC returns array, need to convert to object
const apps = await this.remoteXPCService.browse({
applicationType: opts?.applicationType || 'Any',
applicationType: normalizedOpts?.applicationType || 'Any',
// Use '*' to request all attributes when returnAttributes is not explicitly specified
returnAttributes: opts?.returnAttributes || '*',
returnAttributes: normalizedOpts?.returnAttributes || '*',
});

// Convert array to object keyed by CFBundleIdentifier
Expand Down
2 changes: 1 addition & 1 deletion lib/execute-method-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const executeMethodMap = {
'mobile: listApps': {
command: 'mobileListApps',
params: {
optional: ['applicationType'],
optional: ['applicationType', 'returnAttributes'],
},
},
'mobile: clearApp': {
Expand Down
Loading