Skip to content

Plamen5kov/use xcodebuild instead of xcrun #2678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 3, 2017
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 35 additions & 17 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,31 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
return exportFile;
}

/**
* Exports .xcarchive for AppStore distribution.
*/
public async exportDevelopmentArchive(projectData: IProjectData, buildConfig: IBuildConfig, options: { archivePath: string, exportDir?: string, teamID?: string }): Promise<string> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's public, it should be added to the interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rosen-vladimirov This doesn't have to be public

let platformData = this.getPlatformData(projectData);
let projectRoot = platformData.projectRoot;
let archivePath = options.archivePath;
let buildOutputPath = path.join(projectRoot, "build", "device");

// The xcodebuild exportPath expects directory and writes the <project-name>.ipa at that directory.
let exportPath = path.resolve(options.exportDir || buildOutputPath);
let exportFile = path.join(exportPath, projectData.projectName + ".ipa");

let args = ["-exportArchive",
"-archivePath", archivePath,
"-exportPath", exportPath,
"-exportOptionsPlist", platformData.configurationFilePath
];
await this.$childProcess.spawnFromEvent("xcodebuild", args, "exit",
{ stdio: buildConfig.buildOutputStdio || 'inherit', cwd: this.getPlatformData(projectData).projectRoot },
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: false });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't throwError be true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rosen-vladimirov Not sure, we've set this in the other spawn. I wanted to keep the flags the same?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yyosifov this has been a mistake - it should be true whenever we want to break the operation (i.e. the next operation has no meaning in case this one fails)


return exportFile;
}

private xcbuildProjectArgs(projectRoot: string, projectData: IProjectData, product?: "scheme" | "target"): string[] {
let xcworkspacePath = path.join(projectRoot, projectData.projectName + ".xcworkspace");
if (this.$fs.exists(xcworkspacePath)) {
Expand Down Expand Up @@ -343,7 +368,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });
// this.$logger.out("xcodebuild build succeded.");

await this.createIpa(projectRoot, projectData, buildConfig.buildOutputStdio);
await this.createIpa(projectRoot, projectData, buildConfig);
}

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

private async createIpa(projectRoot: string, projectData: IProjectData, buildOutputStdio?: string): Promise<void> {
let buildOutputPath = path.join(projectRoot, "build", "device");
let xcrunArgs = [
"-sdk", "iphoneos",
"PackageApplication",
path.join(buildOutputPath, projectData.projectName + ".app"),
"-o", path.join(buildOutputPath, projectData.projectName + ".ipa")
];
// if (this.$logger.getLevel() !== "INFO") {
xcrunArgs.push("-verbose");
// }
// this.$logger.out("Packaging project...");
await this.$childProcess.spawnFromEvent("xcrun", xcrunArgs, "exit",
{ stdio: buildOutputStdio || "inherit", cwd: this.getPlatformData(projectData).projectRoot },
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: false });
// this.$logger.out("Project package succeeded.");
private async createIpa(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise<string> {
let xarchivePath = await this.archive(projectData);
let exportFileIpa = await this.exportDevelopmentArchive(projectData,
buildConfig,
{
archivePath: xarchivePath,
});

return exportFileIpa;
}

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