@@ -4,15 +4,13 @@ import path, { dirname } from 'node:path';
44import { fileURLToPath } from 'node:url' ;
55import { log } from './logger' ;
66import _ from 'lodash' ;
7- import { WDA_RUNNER_BUNDLE_ID , PLATFORM_NAME_TVOS } from './constants' ;
7+ import { PLATFORM_NAME_TVOS } from './constants' ;
88import B from 'bluebird' ;
99import _fs from 'node:fs' ;
1010import { waitForCondition } from 'asyncbox' ;
1111import { arch } from 'node:os' ;
1212import type { DeviceInfo } from './types' ;
1313
14- const PROJECT_FILE = 'project.pbxproj' ;
15-
1614// Get current filename - works in both CommonJS and ESM
1715const currentFilename =
1816 typeof __filename !== 'undefined'
@@ -94,47 +92,6 @@ export function isTvOS (platformName: string): boolean {
9492 return _ . toLower ( platformName ) === _ . toLower ( PLATFORM_NAME_TVOS ) ;
9593}
9694
97- /**
98- * Update WebDriverAgentRunner project bundle ID with newBundleId.
99- * This method assumes project file is in the correct state.
100- * @param agentPath - Path to the .xcodeproj directory.
101- * @param newBundleId the new bundle ID used to update.
102- */
103- export async function updateProjectFile ( agentPath : string , newBundleId : string ) : Promise < void > {
104- const projectFilePath = path . resolve ( agentPath , PROJECT_FILE ) ;
105- try {
106- // Assuming projectFilePath is in the correct state, create .old from projectFilePath
107- await fs . copyFile ( projectFilePath , `${ projectFilePath } .old` ) ;
108- await replaceInFile ( projectFilePath , new RegExp ( _ . escapeRegExp ( WDA_RUNNER_BUNDLE_ID ) , 'g' ) , newBundleId ) ;
109- log . debug ( `Successfully updated '${ projectFilePath } ' with bundle id '${ newBundleId } '` ) ;
110- } catch ( err : any ) {
111- log . debug ( `Error updating project file: ${ err . message } ` ) ;
112- log . warn ( `Unable to update project file '${ projectFilePath } ' with ` +
113- `bundle id '${ newBundleId } '. WebDriverAgent may not start` ) ;
114- }
115- }
116-
117- /**
118- * Reset WebDriverAgentRunner project bundle ID to correct state.
119- * @param agentPath - Path to the .xcodeproj directory.
120- */
121- export async function resetProjectFile ( agentPath : string ) : Promise < void > {
122- const projectFilePath = path . join ( agentPath , PROJECT_FILE ) ;
123- try {
124- // restore projectFilePath from .old file
125- if ( ! await fs . exists ( `${ projectFilePath } .old` ) ) {
126- return ; // no need to reset
127- }
128- await fs . mv ( `${ projectFilePath } .old` , projectFilePath ) ;
129- log . debug ( `Successfully reset '${ projectFilePath } ' with bundle id '${ WDA_RUNNER_BUNDLE_ID } '` ) ;
130- } catch ( err : any ) {
131- log . debug ( `Error resetting project file: ${ err . message } ` ) ;
132- log . warn ( `Unable to reset project file '${ projectFilePath } ' with ` +
133- `bundle id '${ WDA_RUNNER_BUNDLE_ID } '. WebDriverAgent has been ` +
134- `modified and not returned to the original state.` ) ;
135- }
136- }
137-
13895export async function setRealDeviceSecurity ( keychainPath : string , keychainPassword : string ) : Promise < void > {
13996 log . debug ( 'Setting security for iOS device' ) ;
14097 await exec ( 'security' , [ '-v' , 'list-keychains' , '-s' , keychainPath ] ) ;
@@ -382,12 +339,4 @@ async function getPIDsUsingPattern (pattern: string): Promise<string[]> {
382339 }
383340}
384341
385- async function replaceInFile ( file : string , find : string | RegExp , replace : string ) : Promise < void > {
386- const contents = await fs . readFile ( file , 'utf8' ) ;
387-
388- const newContents = contents . replace ( find , replace ) ;
389- if ( newContents !== contents ) {
390- await fs . writeFile ( file , newContents , 'utf8' ) ;
391- }
392- }
393342
0 commit comments