Skip to content

Commit 9eecaa1

Browse files
committed
1 parent 0a7408a commit 9eecaa1

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 },
@@ -1312,6 +1326,32 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13121326
}
13131327
return teamId;
13141328
}
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+
}
13151355
}
13161356

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

0 commit comments

Comments
 (0)