@@ -18,6 +18,8 @@ import { select } from '@inquirer/prompts';
1818
1919const execAsync = util . promisify ( exec ) ;
2020const WDA_BUILD_PATH = '/appium_wda_ios/Build/Products/Debug-iphoneos' ;
21+ let bundleIdName : { uuid : string ; name : string } [ ] | null = null ;
22+ let freeBundleID : { uuid : string ; name : string } | null = null ;
2123
2224async function getXcodeMajorVersion ( ) : Promise < number > {
2325 const { stdout } = await execAsync ( 'xcodebuild -version' ) ;
@@ -97,6 +99,23 @@ const getMobileProvisioningFile = async (mobileProvisioningFile?: string) => {
9799 } ) ) ,
98100 } ) ;
99101
102+ const isFreeAccount = await select ( {
103+ message : 'Is this a free or enterprise account provisioning profile?' ,
104+ choices : [
105+ { value : true , name : 'Free Account' } ,
106+ { value : false , name : 'Enterprise Account' } ,
107+ ] ,
108+ } ) ;
109+ if ( isFreeAccount ) {
110+ bundleIdName = provisioningFiles . map ( ( file ) => {
111+ return { uuid : file . UUID , name : `${ file . Name . split ( ':' ) [ 1 ] || file . Name } ` } ;
112+ } ) ;
113+ }
114+ freeBundleID =
115+ bundleIdName ?. find ( ( d : any ) => {
116+ return d . uuid === prompt ;
117+ } ) || null ;
118+
100119 return path . join ( await getProvisioningProfilePath ( ) , `${ prompt } .mobileprovision` ) ;
101120 }
102121} ;
@@ -220,10 +239,21 @@ async function zipPayloadDirectory(
220239 task : async ( context , task ) => {
221240 const wdaBuildPath = path . join ( context . wdaProjectPath , WDA_BUILD_PATH ) ;
222241 const ipaPath = `${ wdaBuildPath } /wda-resign.ipa` ;
223- const as = new Applesign ( {
224- mobileprovision : mobileProvisioningFile ,
225- outfile : ipaPath ,
226- } ) ;
242+
243+ let appleOptions : any ;
244+ if ( freeBundleID ) {
245+ appleOptions = {
246+ mobileprovision : mobileProvisioningFile ,
247+ outfile : ipaPath ,
248+ bundleId : freeBundleID . name . replace ( / ^ \s + | \s + $ / g, '' ) ,
249+ } ;
250+ } else {
251+ appleOptions = {
252+ mobileprovision : mobileProvisioningFile ,
253+ outfile : ipaPath ,
254+ } ;
255+ }
256+ const as = new Applesign ( appleOptions ) ;
227257 await as . signIPA ( path . join ( wdaBuildPath , 'wda-resign.zip' ) ) ;
228258 task . title = `Successfully signed WebDriverAgent file ${ ipaPath } ` ;
229259 } ,
0 commit comments