@@ -251,6 +251,20 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
251
251
let projectRoot = platformData . projectRoot ;
252
252
let archivePath = options . archivePath ;
253
253
let buildOutputPath = path . join ( projectRoot , "build" , "device" ) ;
254
+ let exportOptionsMethod = await this . getExportOptionsMethod ( projectData ) ;
255
+ let plistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
256
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
257
+ <plist version="1.0">
258
+ <dict>
259
+ <key>method</key>
260
+ <string>${ exportOptionsMethod } </string>
261
+ </dict>
262
+ </plist>` ;
263
+
264
+ // Save the options...
265
+ temp . track ( ) ;
266
+ let exportOptionsPlist = temp . path ( { prefix : "export-" , suffix : ".plist" } ) ;
267
+ this . $fs . writeFile ( exportOptionsPlist , plistTemplate ) ;
254
268
255
269
// The xcodebuild exportPath expects directory and writes the <project-name>.ipa at that directory.
256
270
let exportPath = path . resolve ( options . exportDir || buildOutputPath ) ;
@@ -259,7 +273,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
259
273
let args = [ "-exportArchive" ,
260
274
"-archivePath" , archivePath ,
261
275
"-exportPath" , exportPath ,
262
- "-exportOptionsPlist" , platformData . configurationFilePath
276
+ "-exportOptionsPlist" , exportOptionsPlist
263
277
] ;
264
278
await this . $childProcess . spawnFromEvent ( "xcodebuild" , args , "exit" ,
265
279
{ stdio : buildConfig . buildOutputStdio || 'inherit' , cwd : this . getPlatformData ( projectData ) . projectRoot } ,
@@ -1312,6 +1326,32 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
1312
1326
}
1313
1327
return teamId ;
1314
1328
}
1329
+
1330
+ private async getEmbeddedPlistData ( projectData : IProjectData ) : Promise < IDictionary < any > > {
1331
+ let embeddedPlistContents = "" ;
1332
+ const embeddedMobileProvisionPath = path . join ( this . getPlatformData ( projectData ) . deviceBuildOutputPath , `${ projectData . projectName } .app` , "embedded.mobileprovision" ) ;
1333
+
1334
+ embeddedPlistContents = await this . $childProcess . exec ( `security cms -D -i ${ embeddedMobileProvisionPath } ` ) ;
1335
+
1336
+ return plist . parse ( embeddedPlistContents ) ;
1337
+ }
1338
+
1339
+ private async getExportOptionsMethod ( projectData : IProjectData ) : Promise < "app-store" | "ad-hoc" | "enterprise" | "development" > {
1340
+ const embeddedPlistData = await this . getEmbeddedPlistData ( projectData ) ;
1341
+
1342
+ if ( embeddedPlistData . ProvisionsAllDevices ) {
1343
+ return "enterprise" ;
1344
+ } else if ( embeddedPlistData . ProvisionedDevices && embeddedPlistData . ProvisionedDevices . length ) {
1345
+ const entitlements = embeddedPlistData . Entitlements ;
1346
+ if ( entitlements [ "get-task-allow" ] ) {
1347
+ return "development" ;
1348
+ } else {
1349
+ return "ad-hoc" ;
1350
+ }
1351
+ } else {
1352
+ return "app-store" ;
1353
+ }
1354
+ }
1315
1355
}
1316
1356
1317
1357
$injector . register ( "iOSProjectService" , IOSProjectService ) ;
0 commit comments