Skip to content

Commit ac301ba

Browse files
PeterStaevrosen-vladimirov
authored andcommitted
fixes #3020
1 parent cc99451 commit ac301ba

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

lib/services/ios-project-service.ts

+41-1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,20 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
251251
let projectRoot = platformData.projectRoot;
252252
let archivePath = options.archivePath;
253253
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);
254268

255269
// The xcodebuild exportPath expects directory and writes the <project-name>.ipa at that directory.
256270
let exportPath = path.resolve(options.exportDir || buildOutputPath);
@@ -259,7 +273,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
259273
let args = ["-exportArchive",
260274
"-archivePath", archivePath,
261275
"-exportPath", exportPath,
262-
"-exportOptionsPlist", platformData.configurationFilePath
276+
"-exportOptionsPlist", exportOptionsPlist
263277
];
264278
await this.$childProcess.spawnFromEvent("xcodebuild", args, "exit",
265279
{ 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
13311345
this.$logger.warnWithLabel("The CFBundleIdentifier key inside the 'Info.plist' will be overriden by the 'id' inside 'package.json'.");
13321346
}
13331347
}
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+
}
13341374
}
13351375

13361376
$injector.register("iOSProjectService", IOSProjectService);

0 commit comments

Comments
 (0)