Skip to content

Commit 3ab47d6

Browse files
committed
Setup the provisioningProfiles in the exportOptions plist, provide quiet flags to xcodebuild and gradle, provide -allowProvisioningUpdates to xcodebuild > 9.0
1 parent db969b6 commit 3ab47d6

File tree

3 files changed

+68
-45
lines changed

3 files changed

+68
-45
lines changed

lib/commands/appstore-upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class PublishIOS implements ICommand {
8383
let archivePath = await iOSProjectService.archive(this.$projectData);
8484
this.$logger.info("Archive at: " + archivePath);
8585

86-
let exportPath = await iOSProjectService.exportArchive(this.$projectData, { archivePath, teamID });
86+
let exportPath = await iOSProjectService.exportArchive(this.$projectData, { archivePath, teamID, provision: mobileProvisionIdentifier || this.$options.provision });
8787
this.$logger.info("Export at: " + exportPath);
8888

8989
ipaFilePath = exportPath;

lib/services/android-project-service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
517517
if (this.$androidToolsInfo.getToolsInfo().androidHomeEnvVar) {
518518
const gradlew = this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew";
519519

520+
const localArgs = [...gradleArgs];
521+
if (this.$logger.getLevel() === "INFO") {
522+
localArgs.push("--quiet");
523+
this.$logger.info(`${gradlew} ${localArgs.join(" ")}`);
524+
}
525+
520526
childProcessOpts = childProcessOpts || {};
521527
childProcessOpts.cwd = childProcessOpts.cwd || projectRoot;
522528
childProcessOpts.stdio = childProcessOpts.stdio || "inherit";
523529

524530
return await this.spawn(gradlew,
525-
gradleArgs,
531+
localArgs,
526532
childProcessOpts,
527533
spawnFromEventOptions);
528534
}

lib/services/ios-project-service.ts

Lines changed: 60 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
194194
let args = ["archive", "-archivePath", archivePath, "-configuration",
195195
(!buildConfig || buildConfig.release) ? "Release" : "Debug"]
196196
.concat(this.xcbuildProjectArgs(projectRoot, projectData, "scheme"));
197-
await this.$childProcess.spawnFromEvent("xcodebuild", args, "exit", { stdio: 'inherit' });
197+
await this.xcodebuild(args, projectRoot, buildConfig.buildOutputStdio);
198198
return archivePath;
199199
}
200200

201201
/**
202202
* Exports .xcarchive for AppStore distribution.
203203
*/
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;
207207
// 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");
210210

211211
// These are the options that you can set in the Xcode UI when exporting for AppStore deployment.
212212
let plistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
@@ -218,6 +218,13 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
218218
plistTemplate += ` <key>teamID</key>
219219
<string>${options.teamID}</string>
220220
`;
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>`;
221228
}
222229
plistTemplate += ` <key>method</key>
223230
<string>app-store</string>
@@ -230,23 +237,24 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
230237

231238
// Save the options...
232239
temp.track();
233-
let exportOptionsPlist = temp.path({ prefix: "export-", suffix: ".plist" });
240+
const exportOptionsPlist = temp.path({ prefix: "export-", suffix: ".plist" });
234241
this.$fs.writeFile(exportOptionsPlist, plistTemplate);
235242

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);
243251
return exportFile;
244252
}
245253

246254
/**
247255
* Exports .xcarchive for a development device.
248256
*/
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> {
250258
let platformData = this.getPlatformData(projectData);
251259
let projectRoot = platformData.projectRoot;
252260
let archivePath = options.archivePath;
@@ -257,7 +265,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
257265
<plist version="1.0">
258266
<dict>
259267
<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 += `
261277
<key>uploadBitcode</key>
262278
<false/>
263279
</dict>
@@ -272,15 +288,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
272288
let exportPath = path.resolve(options.exportDir || buildOutputPath);
273289
let exportFile = path.join(exportPath, projectData.projectName + ".ipa");
274290

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);
284299
return exportFile;
285300
}
286301

@@ -400,15 +415,25 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
400415
args.push(`DEVELOPMENT_TEAM=${buildConfig.teamId}`);
401416
}
402417

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,
406434
"exit",
407-
{ stdio: buildConfig.buildOutputStdio || "inherit", cwd: this.getPlatformData(projectData).projectRoot },
435+
{ stdio: stdio || "inherit", cwd },
408436
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });
409-
// this.$logger.out("xcodebuild build succeded.");
410-
411-
await this.createIpa(projectRoot, projectData, buildConfig);
412437
}
413438

414439
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
493518
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator"),
494519
"CODE_SIGN_IDENTITY="
495520
]);
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);
500522
}
501523

502524
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 });
510527
return exportFileIpa;
511528
}
512529

0 commit comments

Comments
 (0)