@@ -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 } ,
@@ -1331,6 +1345,32 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
1331
1345
this . $logger . warnWithLabel ( "The CFBundleIdentifier key inside the 'Info.plist' will be overriden by the 'id' inside 'package.json'." ) ;
1332
1346
}
1333
1347
}
1348
+
1349
+ private async getEmbeddedPlistData ( projectData : IProjectData ) : Promise < IDictionary < any > > {
1350
+ let embeddedPlistContents = "" ;
1351
+ const embeddedMobileProvisionPath = path . join ( this . getPlatformData ( projectData ) . deviceBuildOutputPath , `${ projectData . projectName } .app` , "embedded.mobileprovision" ) ;
1352
+
1353
+ embeddedPlistContents = await this . $childProcess . exec ( `security cms -D -i ${ embeddedMobileProvisionPath } ` ) ;
1354
+
1355
+ return plist . parse ( embeddedPlistContents ) ;
1356
+ }
1357
+
1358
+ private async getExportOptionsMethod ( projectData : IProjectData ) : Promise < "app-store" | "ad-hoc" | "enterprise" | "development" > {
1359
+ const embeddedPlistData = await this . getEmbeddedPlistData ( projectData ) ;
1360
+
1361
+ if ( embeddedPlistData . ProvisionsAllDevices ) {
1362
+ return "enterprise" ;
1363
+ } else if ( embeddedPlistData . ProvisionedDevices && embeddedPlistData . ProvisionedDevices . length ) {
1364
+ const entitlements = embeddedPlistData . Entitlements ;
1365
+ if ( entitlements [ "get-task-allow" ] ) {
1366
+ return "development" ;
1367
+ } else {
1368
+ return "ad-hoc" ;
1369
+ }
1370
+ } else {
1371
+ return "app-store" ;
1372
+ }
1373
+ }
1334
1374
}
1335
1375
1336
1376
$injector . register ( "iOSProjectService" , IOSProjectService ) ;
0 commit comments