@@ -194,19 +194,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
194
194
let args = [ "archive" , "-archivePath" , archivePath , "-configuration" ,
195
195
( ! buildConfig || buildConfig . release ) ? "Release" : "Debug" ]
196
196
. concat ( this . xcbuildProjectArgs ( projectRoot , projectData , "scheme" ) ) ;
197
- await this . $childProcess . spawnFromEvent ( " xcodebuild" , args , "exit" , { stdio : 'inherit' } ) ;
197
+ await this . xcodebuild ( args , projectRoot , buildConfig . buildOutputStdio ) ;
198
198
return archivePath ;
199
199
}
200
200
201
201
/**
202
202
* Exports .xcarchive for AppStore distribution.
203
203
*/
204
- public async exportArchive ( projectData : IProjectData , options : { archivePath : string , exportDir ?: string , teamID ?: string } ) : Promise < string > {
205
- let projectRoot = this . getPlatformData ( projectData ) . projectRoot ;
206
- let archivePath = options . archivePath ;
204
+ public async exportArchive ( projectData : IProjectData , options : { archivePath : string , exportDir ?: string , teamID ?: string , provision ?: string } ) : Promise < string > {
205
+ const projectRoot = this . getPlatformData ( projectData ) . projectRoot ;
206
+ const archivePath = options . archivePath ;
207
207
// The xcodebuild exportPath expects directory and writes the <project-name>.ipa at that directory.
208
- let exportPath = path . resolve ( options . exportDir || path . join ( projectRoot , "/build/archive" ) ) ;
209
- let exportFile = path . join ( exportPath , projectData . projectName + ".ipa" ) ;
208
+ const exportPath = path . resolve ( options . exportDir || path . join ( projectRoot , "/build/archive" ) ) ;
209
+ const exportFile = path . join ( exportPath , projectData . projectName + ".ipa" ) ;
210
210
211
211
// These are the options that you can set in the Xcode UI when exporting for AppStore deployment.
212
212
let plistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
@@ -218,6 +218,13 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
218
218
plistTemplate += ` <key>teamID</key>
219
219
<string>${ options . teamID } </string>
220
220
` ;
221
+ }
222
+ if ( options && options . provision ) {
223
+ plistTemplate += ` <key>provisioningProfiles</key>
224
+ <dict>
225
+ <key>${ projectData . projectId } </key>
226
+ <string>${ options . provision } </string>
227
+ </dict>` ;
221
228
}
222
229
plistTemplate += ` <key>method</key>
223
230
<string>app-store</string>
@@ -230,23 +237,24 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
230
237
231
238
// Save the options...
232
239
temp . track ( ) ;
233
- let exportOptionsPlist = temp . path ( { prefix : "export-" , suffix : ".plist" } ) ;
240
+ const exportOptionsPlist = temp . path ( { prefix : "export-" , suffix : ".plist" } ) ;
234
241
this . $fs . writeFile ( exportOptionsPlist , plistTemplate ) ;
235
242
236
- let args = [ "-exportArchive" ,
237
- "-archivePath" , archivePath ,
238
- "-exportPath" , exportPath ,
239
- "-exportOptionsPlist" , exportOptionsPlist
240
- ] ;
241
- await this . $childProcess . spawnFromEvent ( "xcodebuild" , args , "exit" , { stdio : 'inherit' } ) ;
242
-
243
+ await this . xcodebuild (
244
+ [
245
+ "-exportArchive" ,
246
+ "-archivePath" , archivePath ,
247
+ "-exportPath" , exportPath ,
248
+ "-exportOptionsPlist" , exportOptionsPlist
249
+ ] ,
250
+ projectRoot ) ;
243
251
return exportFile ;
244
252
}
245
253
246
254
/**
247
255
* Exports .xcarchive for a development device.
248
256
*/
249
- private async exportDevelopmentArchive ( projectData : IProjectData , buildConfig : IBuildConfig , options : { archivePath : string , exportDir ?: string , teamID ?: string } ) : Promise < string > {
257
+ private async exportDevelopmentArchive ( projectData : IProjectData , buildConfig : IBuildConfig , options : { archivePath : string , exportDir ?: string , teamID ?: string , provision ?: string } ) : Promise < string > {
250
258
let platformData = this . getPlatformData ( projectData ) ;
251
259
let projectRoot = platformData . projectRoot ;
252
260
let archivePath = options . archivePath ;
@@ -257,7 +265,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
257
265
<plist version="1.0">
258
266
<dict>
259
267
<key>method</key>
260
- <string>${ exportOptionsMethod } </string>
268
+ <string>${ exportOptionsMethod } </string>` ;
269
+ if ( options && options . provision ) {
270
+ plistTemplate += ` <key>provisioningProfiles</key>
271
+ <dict>
272
+ <key>${ projectData . projectId } </key>
273
+ <string>${ options . provision } </string>
274
+ </dict>` ;
275
+ }
276
+ plistTemplate += `
261
277
<key>uploadBitcode</key>
262
278
<false/>
263
279
</dict>
@@ -272,15 +288,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
272
288
let exportPath = path . resolve ( options . exportDir || buildOutputPath ) ;
273
289
let exportFile = path . join ( exportPath , projectData . projectName + ".ipa" ) ;
274
290
275
- let args = [ "-exportArchive" ,
276
- "-archivePath" , archivePath ,
277
- "-exportPath" , exportPath ,
278
- "-exportOptionsPlist" , exportOptionsPlist
279
- ] ;
280
- await this . $childProcess . spawnFromEvent ( "xcodebuild" , args , "exit" ,
281
- { stdio : buildConfig . buildOutputStdio || 'inherit' , cwd : this . getPlatformData ( projectData ) . projectRoot } ,
282
- { emitOptions : { eventName : constants . BUILD_OUTPUT_EVENT_NAME } , throwError : true } ) ;
283
-
291
+ await this . xcodebuild (
292
+ [
293
+ "-exportArchive" ,
294
+ "-archivePath" , archivePath ,
295
+ "-exportPath" , exportPath ,
296
+ "-exportOptionsPlist" , exportOptionsPlist
297
+ ] ,
298
+ projectRoot , buildConfig . buildOutputStdio ) ;
284
299
return exportFile ;
285
300
}
286
301
@@ -400,15 +415,25 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
400
415
args . push ( `DEVELOPMENT_TEAM=${ buildConfig . teamId } ` ) ;
401
416
}
402
417
403
- // this.$logger.out("xcodebuild...");
404
- await this . $childProcess . spawnFromEvent ( "xcodebuild" ,
405
- args ,
418
+ await this . xcodebuild ( args , projectRoot , buildConfig . buildOutputStdio ) ;
419
+ await this . createIpa ( projectRoot , projectData , buildConfig ) ;
420
+ }
421
+
422
+ private async xcodebuild ( args : string [ ] , cwd : string , stdio : any = "inherit" ) : Promise < ISpawnResult > {
423
+ const localArgs = [ ...args ] ;
424
+ const xcodeBuildVersion = await this . getXcodeVersion ( ) ;
425
+ if ( helpers . versionCompare ( xcodeBuildVersion , "9.0" ) >= 0 ) {
426
+ localArgs . push ( "-allowProvisioningUpdates" ) ;
427
+ }
428
+ if ( this . $logger . getLevel ( ) === "INFO" ) {
429
+ localArgs . push ( "-quiet" ) ;
430
+ this . $logger . info ( `xcodebuild ${ localArgs . join ( " " ) } ` ) ;
431
+ }
432
+ return await this . $childProcess . spawnFromEvent ( "xcodebuild" ,
433
+ localArgs ,
406
434
"exit" ,
407
- { stdio : buildConfig . buildOutputStdio || "inherit" , cwd : this . getPlatformData ( projectData ) . projectRoot } ,
435
+ { stdio : stdio || "inherit" , cwd } ,
408
436
{ emitOptions : { eventName : constants . BUILD_OUTPUT_EVENT_NAME } , throwError : true } ) ;
409
- // this.$logger.out("xcodebuild build succeded.");
410
-
411
- await this . createIpa ( projectRoot , projectData , buildConfig ) ;
412
437
}
413
438
414
439
private async setupSigningFromProvision ( projectRoot : string , projectData : IProjectData , provision ?: string , mobileProvisionData ?: mobileprovision . provision . MobileProvision ) : Promise < void > {
@@ -493,20 +518,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
493
518
"CONFIGURATION_BUILD_DIR=" + path . join ( projectRoot , "build" , "emulator" ) ,
494
519
"CODE_SIGN_IDENTITY="
495
520
] ) ;
496
-
497
- await this . $childProcess . spawnFromEvent ( "xcodebuild" , args , "exit" ,
498
- { stdio : buildOutputStdio || "inherit" , cwd : this . getPlatformData ( projectData ) . projectRoot } ,
499
- { emitOptions : { eventName : constants . BUILD_OUTPUT_EVENT_NAME } , throwError : true } ) ;
521
+ await this . xcodebuild ( args , projectRoot , buildOutputStdio ) ;
500
522
}
501
523
502
524
private async createIpa ( projectRoot : string , projectData : IProjectData , buildConfig : IBuildConfig ) : Promise < string > {
503
- let xarchivePath = await this . archive ( projectData , buildConfig ) ;
504
- let exportFileIpa = await this . exportDevelopmentArchive ( projectData ,
505
- buildConfig ,
506
- {
507
- archivePath : xarchivePath ,
508
- } ) ;
509
-
525
+ const archivePath = await this . archive ( projectData , buildConfig ) ;
526
+ const exportFileIpa = await this . exportDevelopmentArchive ( projectData , buildConfig , { archivePath, provision : buildConfig . provision || buildConfig . mobileProvisionIdentifier } ) ;
510
527
return exportFileIpa ;
511
528
}
512
529
0 commit comments