Skip to content

Commit 1b7d603

Browse files
authored
Plamen5kov/use xcodebuild instead of xcrun (#2678)
* wip: fix for xcrun * Change createIPA to use xcodebuild instead of xcrrun because of breaking change in xcode 8.3 * fix lint * Make method exportDevArchive method private and set throw exceptions to true on xcodebuild
1 parent fadb4ce commit 1b7d603

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

lib/services/ios-project-service.ts

+35-17
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,31 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
230230
return exportFile;
231231
}
232232

233+
/**
234+
* Exports .xcarchive for a development device.
235+
*/
236+
private async exportDevelopmentArchive(projectData: IProjectData, buildConfig: IBuildConfig, options: { archivePath: string, exportDir?: string, teamID?: string }): Promise<string> {
237+
let platformData = this.getPlatformData(projectData);
238+
let projectRoot = platformData.projectRoot;
239+
let archivePath = options.archivePath;
240+
let buildOutputPath = path.join(projectRoot, "build", "device");
241+
242+
// The xcodebuild exportPath expects directory and writes the <project-name>.ipa at that directory.
243+
let exportPath = path.resolve(options.exportDir || buildOutputPath);
244+
let exportFile = path.join(exportPath, projectData.projectName + ".ipa");
245+
246+
let args = ["-exportArchive",
247+
"-archivePath", archivePath,
248+
"-exportPath", exportPath,
249+
"-exportOptionsPlist", platformData.configurationFilePath
250+
];
251+
await this.$childProcess.spawnFromEvent("xcodebuild", args, "exit",
252+
{ stdio: buildConfig.buildOutputStdio || 'inherit', cwd: this.getPlatformData(projectData).projectRoot },
253+
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });
254+
255+
return exportFile;
256+
}
257+
233258
private xcbuildProjectArgs(projectRoot: string, projectData: IProjectData, product?: "scheme" | "target"): string[] {
234259
let xcworkspacePath = path.join(projectRoot, projectData.projectName + ".xcworkspace");
235260
if (this.$fs.exists(xcworkspacePath)) {
@@ -343,7 +368,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
343368
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });
344369
// this.$logger.out("xcodebuild build succeded.");
345370

346-
await this.createIpa(projectRoot, projectData, buildConfig.buildOutputStdio);
371+
await this.createIpa(projectRoot, projectData, buildConfig);
347372
}
348373

349374
private async setupSigningFromProvision(projectRoot: string, projectData: IProjectData, provision?: any): Promise<void> {
@@ -430,22 +455,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
430455
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: false });
431456
}
432457

433-
private async createIpa(projectRoot: string, projectData: IProjectData, buildOutputStdio?: string): Promise<void> {
434-
let buildOutputPath = path.join(projectRoot, "build", "device");
435-
let xcrunArgs = [
436-
"-sdk", "iphoneos",
437-
"PackageApplication",
438-
path.join(buildOutputPath, projectData.projectName + ".app"),
439-
"-o", path.join(buildOutputPath, projectData.projectName + ".ipa")
440-
];
441-
// if (this.$logger.getLevel() !== "INFO") {
442-
xcrunArgs.push("-verbose");
443-
// }
444-
// this.$logger.out("Packaging project...");
445-
await this.$childProcess.spawnFromEvent("xcrun", xcrunArgs, "exit",
446-
{ stdio: buildOutputStdio || "inherit", cwd: this.getPlatformData(projectData).projectRoot },
447-
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: false });
448-
// this.$logger.out("Project package succeeded.");
458+
private async createIpa(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise<string> {
459+
let xarchivePath = await this.archive(projectData);
460+
let exportFileIpa = await this.exportDevelopmentArchive(projectData,
461+
buildConfig,
462+
{
463+
archivePath: xarchivePath,
464+
});
465+
466+
return exportFileIpa;
449467
}
450468

451469
public isPlatformPrepared(projectRoot: string, projectData: IProjectData): boolean {

0 commit comments

Comments
 (0)