-
-
Notifications
You must be signed in to change notification settings - Fork 459
feat(installation-proxy): use remotexpc when iOS>=18 #2714
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
Merged
mykola-mokhnach
merged 15 commits into
appium:master
from
navin772:remotexpc-installation-proxy
Feb 4, 2026
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0949125
use remotexpc for installation proxy when iOS>=18
navin772 29fb064
merge branch master
navin772 7ed803a
pass `clientOptions` directly
navin772 3ba24db
fix formatting
navin772 e343120
address review comments
navin772 5c435ab
Merge branch 'master' into remotexpc-installation-proxy
navin772 a5532a7
return progress msg in case of remotexpc similar to ios-device
navin772 48e63b1
timeouts for remotexpc
navin772 fbb54bf
resolve merge conflicts
navin772 666c69c
address review comments
navin772 0f0d708
Merge branch 'master' into remotexpc-installation-proxy
navin772 7440270
add `ProgressResponse` interface
navin772 a2bf7af
return all attributes using '*
navin772 013fb0e
return early in case of ios-device
navin772 a10452b
update docs
navin772 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,292 @@ | ||
| import {getRemoteXPCServices} from './remotexpc-utils'; | ||
| import {log} from '../logger'; | ||
| import {services} from 'appium-ios-device'; | ||
| import type {InstallationProxyService as IOSDeviceInstallationProxyService} from 'appium-ios-device'; | ||
| import type { | ||
| InstallationProxyService as RemoteXPCInstallationProxyService, | ||
| RemoteXpcConnection, | ||
| } from 'appium-ios-remotexpc'; | ||
|
|
||
| /** | ||
| * Application information interface | ||
| */ | ||
| interface AppInfo { | ||
| CFBundleIdentifier?: string; | ||
| CFBundleName?: string; | ||
| CFBundleDisplayName?: string; | ||
| CFBundleVersion?: string; | ||
| CFBundleShortVersionString?: string; | ||
| ApplicationType?: string; | ||
| Path?: string; | ||
| Container?: string; | ||
| StaticDiskUsage?: number; | ||
| DynamicDiskUsage?: number; | ||
| [key: string]: any; | ||
| } | ||
|
|
||
| /** | ||
| * Options for listing applications | ||
| */ | ||
| interface ListApplicationOptions { | ||
| applicationType?: 'User' | 'System'; | ||
| returnAttributes?: string[]; | ||
| } | ||
|
|
||
| /** | ||
| * Options for lookup applications | ||
| */ | ||
| interface LookupApplicationOptions { | ||
| bundleIds: string | string[]; | ||
| returnAttributes?: string[]; | ||
| applicationType?: 'User' | 'System'; | ||
| } | ||
|
|
||
| /** | ||
| * Unified Installation Proxy Client | ||
| * | ||
| * Provides a unified interface for app installation/management operations on iOS devices | ||
| */ | ||
| export class InstallationProxyClient { | ||
| private constructor( | ||
| private readonly service: RemoteXPCInstallationProxyService | IOSDeviceInstallationProxyService, | ||
| private readonly remoteXPCConnection?: RemoteXpcConnection | ||
| ) {} | ||
|
|
||
| //#region Public Methods | ||
|
|
||
| /** | ||
| * Create an InstallationProxy client for the device | ||
| * | ||
| * @param udid - Device UDID | ||
| * @param useRemoteXPC - Whether to use RemoteXPC | ||
| * @returns InstallationProxy client instance | ||
| */ | ||
| static async create(udid: string, useRemoteXPC: boolean): Promise<InstallationProxyClient> { | ||
| if (useRemoteXPC) { | ||
| const client = await InstallationProxyClient.withRemoteXpcConnection(async () => { | ||
| const Services = await getRemoteXPCServices(); | ||
| const {installationProxyService, remoteXPC} = await Services.startInstallationProxyService(udid); | ||
| return { | ||
| service: installationProxyService, | ||
| connection: remoteXPC, | ||
| }; | ||
| }); | ||
| if (client) { | ||
| return client; | ||
| } | ||
| } | ||
|
|
||
| const service = await services.startInstallationProxyService(udid); | ||
| return new InstallationProxyClient(service); | ||
| } | ||
|
|
||
| /** | ||
| * List installed applications | ||
| * | ||
| * @param opts - Options for filtering and selecting attributes | ||
| * @returns Object keyed by bundle ID | ||
| */ | ||
| async listApplications(opts?: ListApplicationOptions): Promise<Record<string, AppInfo>> { | ||
| if (this.isRemoteXPC) { | ||
| // RemoteXPC returns array, need to convert to object | ||
| const apps = await this.remoteXPCService.browse({ | ||
| applicationType: opts?.applicationType || 'Any', | ||
| returnAttributes: opts?.returnAttributes, | ||
| }); | ||
|
|
||
| // Convert array to object keyed by CFBundleIdentifier | ||
| return apps.reduce((acc, app) => { | ||
| if (app.CFBundleIdentifier) { | ||
| acc[app.CFBundleIdentifier] = app; | ||
| } | ||
| return acc; | ||
| }, {} as Record<string, AppInfo>); | ||
| } | ||
|
|
||
| // ios-device already returns object | ||
| return await this.iosDeviceService.listApplications(opts); | ||
| } | ||
|
|
||
| /** | ||
| * Look up application information for specific bundle IDs | ||
| * | ||
| * @param opts - Bundle IDs and options | ||
| * @returns Object keyed by bundle ID | ||
| */ | ||
| async lookupApplications(opts: LookupApplicationOptions): Promise<Record<string, AppInfo>> { | ||
navin772 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const bundleIds = Array.isArray(opts.bundleIds) ? opts.bundleIds : [opts.bundleIds]; | ||
|
|
||
| if (this.isRemoteXPC) { | ||
| return await this.remoteXPCService.lookup(bundleIds, { | ||
| returnAttributes: opts.returnAttributes, | ||
| applicationType: opts.applicationType, | ||
| }); | ||
| } | ||
|
|
||
| return await this.iosDeviceService.lookupApplications(opts); | ||
| } | ||
|
|
||
| /** | ||
| * Install an application | ||
| * | ||
| * @param path - Path to ipa | ||
| * @param clientOptions - Installation options | ||
| * @param timeout - Timeout in milliseconds | ||
| * @returns Array of progress messages received during installation | ||
| */ | ||
| async installApplication( | ||
| path: string, | ||
| clientOptions?: Record<string, any>, | ||
| timeout?: number | ||
navin772 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ): Promise<any[]> { | ||
| if (this.isRemoteXPC) { | ||
| return await this.executeWithProgressCollection( | ||
| (progressHandler) => this.remoteXPCService.install( | ||
| path, | ||
| {...clientOptions, timeoutMs: timeout}, | ||
| progressHandler | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| return await this.iosDeviceService.installApplication(path, clientOptions, timeout); | ||
| } | ||
|
|
||
| /** | ||
| * Upgrade an application | ||
| * | ||
| * @param path - Path to app on device | ||
| * @param clientOptions - Installation options | ||
| * @param timeout - Timeout in milliseconds | ||
| * @returns Array of progress messages received during upgrade | ||
| */ | ||
| async upgradeApplication( | ||
| path: string, | ||
| clientOptions?: Record<string, any>, | ||
| timeout?: number | ||
| ): Promise<any[]> { | ||
| if (this.isRemoteXPC) { | ||
| return await this.executeWithProgressCollection( | ||
| (progressHandler) => this.remoteXPCService.upgrade( | ||
| path, | ||
| {...clientOptions, timeoutMs: timeout}, | ||
| progressHandler | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| return await this.iosDeviceService.upgradeApplication(path, clientOptions, timeout); | ||
| } | ||
|
|
||
| /** | ||
| * Uninstall an application | ||
| * | ||
| * @param bundleId - Bundle ID of app to uninstall | ||
| * @param timeout - Timeout in milliseconds | ||
| * @returns Array of progress messages received during uninstallation | ||
| */ | ||
| async uninstallApplication(bundleId: string, timeout?: number): Promise<any[]> { | ||
| if (this.isRemoteXPC) { | ||
| return await this.executeWithProgressCollection( | ||
| (progressHandler) => this.remoteXPCService.uninstall( | ||
| bundleId, | ||
| {timeoutMs: timeout}, | ||
| progressHandler | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| return await this.iosDeviceService.uninstallApplication(bundleId, timeout); | ||
| } | ||
|
|
||
| /** | ||
| * Close the client and cleanup resources | ||
| */ | ||
| async close(): Promise<void> { | ||
| try { | ||
| this.service.close(); | ||
| } catch (err: any) { | ||
| log.debug(`Error closing installation proxy service: ${err.message}`); | ||
| } | ||
|
|
||
| if (this.remoteXPCConnection) { | ||
| try { | ||
| await this.remoteXPCConnection.close(); | ||
| } catch (err: any) { | ||
| log.warn(`Error closing RemoteXPC connection: ${err.message}`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| //#endregion | ||
|
|
||
| //#region Private Methods | ||
|
|
||
| /** | ||
| * Check if this client is using RemoteXPC | ||
| */ | ||
| private get isRemoteXPC(): boolean { | ||
| return !!this.remoteXPCConnection; | ||
| } | ||
|
|
||
| /** | ||
| * Get the RemoteXPC service (throws if not RemoteXPC) | ||
| */ | ||
| private get remoteXPCService(): RemoteXPCInstallationProxyService { | ||
| return this.service as RemoteXPCInstallationProxyService; | ||
| } | ||
|
|
||
| /** | ||
| * Get the ios-device service (throws if not ios-device) | ||
| */ | ||
| private get iosDeviceService(): IOSDeviceInstallationProxyService { | ||
| return this.service as IOSDeviceInstallationProxyService; | ||
| } | ||
|
|
||
| /** | ||
| * Execute a RemoteXPC operation and collect progress messages to match ios-device behavior | ||
| * | ||
| * @param operation - Function that executes the RemoteXPC operation with a progress handler | ||
| * @returns Array of progress messages | ||
| */ | ||
| private async executeWithProgressCollection( | ||
| operation: (progressHandler: (percentComplete: number, status: string) => void) => Promise<void> | ||
| ): Promise<any[]> { | ||
| const messages: any[] = []; | ||
navin772 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await operation((percentComplete, status) => { | ||
| messages.push({PercentComplete: percentComplete, Status: status}); | ||
| }); | ||
| return messages; | ||
| } | ||
|
|
||
| /** | ||
| * Helper to safely execute RemoteXPC operations with connection cleanup | ||
| */ | ||
| private static async withRemoteXpcConnection<T extends RemoteXPCInstallationProxyService | IOSDeviceInstallationProxyService>( | ||
| operation: () => Promise<{service: T; connection: RemoteXpcConnection}> | ||
| ): Promise<InstallationProxyClient | null> { | ||
| let remoteXPCConnection: RemoteXpcConnection | undefined; | ||
| let succeeded = false; | ||
| try { | ||
| const {service, connection} = await operation(); | ||
| remoteXPCConnection = connection; | ||
| const client = new InstallationProxyClient(service, remoteXPCConnection); | ||
| succeeded = true; | ||
| return client; | ||
| } catch (err: any) { | ||
| log.error(`Failed to create InstallationProxy client via RemoteXPC: ${err.message}, falling back to appium-ios-device`); | ||
| return null; | ||
navin772 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } finally { | ||
| // Only close connection if we failed (if succeeded, the client owns it) | ||
| if (!succeeded && remoteXPCConnection) { | ||
| try { | ||
| await remoteXPCConnection.close(); | ||
| } catch (closeErr: any) { | ||
| log.debug(`Error closing RemoteXPC connection during cleanup: ${closeErr.message}`); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| //#endregion | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.