From ab3638f8da9a645cf9124e7651c21095108725a1 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Fri, 31 Mar 2017 12:04:37 +0300 Subject: [PATCH 1/4] wip: fix for xcrun --- lib/services/ios-project-service.ts | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 48a16f9762..2800b98c7c 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -343,7 +343,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 { @@ -430,24 +430,26 @@ 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 { + private async createIpa(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise { 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 }, + + let exportOptionsPath = this.exportArchive(projectData, {buildConfig.team }); + let xcrunArgs = this.getXcodeArchiveArgs(projectData.projectName, projectRoot, buildOutputPath, exportOptionsPath); + await this.$childProcess.spawnFromEvent("xcodebuild", xcrunArgs, "exit", + { stdio: buildConfig.buildOutputStdio || "inherit", cwd: this.getPlatformData(projectData).projectRoot }, { emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: false }); // this.$logger.out("Project package succeeded."); } + private getXcodeArchiveArgs(projectName: string, projectPath: string, outputPath, exportOptionsPath): Array { + return [ + '-exportArchive', + '-archivePath', projectName + '.xcarchive', + '-exportOptionsPlist', exportOptionsPath, + '-exportPath', outputPath + ]; + } + public isPlatformPrepared(projectRoot: string, projectData: IProjectData): boolean { return this.$fs.exists(path.join(projectRoot, projectData.projectName, constants.APP_FOLDER_NAME)); } From 14f80c89e5b65f9db7ccff9a608985a2a7bb16be Mon Sep 17 00:00:00 2001 From: Yosif Yosifov Date: Fri, 31 Mar 2017 15:46:54 +0300 Subject: [PATCH 2/4] Change createIPA to use xcodebuild instead of xcrrun because of breaking change in xcode 8.3 --- lib/services/ios-project-service.ts | 53 +++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 2800b98c7c..6a628641bd 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -230,6 +230,32 @@ 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 { + 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 .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 }); + + 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)) { @@ -430,24 +456,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ { emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: false }); } - private async createIpa(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise { - let buildOutputPath = path.join(projectRoot, "build", "device"); - - let exportOptionsPath = this.exportArchive(projectData, {buildConfig.team }); - let xcrunArgs = this.getXcodeArchiveArgs(projectData.projectName, projectRoot, buildOutputPath, exportOptionsPath); - await this.$childProcess.spawnFromEvent("xcodebuild", xcrunArgs, "exit", - { stdio: buildConfig.buildOutputStdio || "inherit", cwd: this.getPlatformData(projectData).projectRoot }, - { emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: false }); - // this.$logger.out("Project package succeeded."); - } - - private getXcodeArchiveArgs(projectName: string, projectPath: string, outputPath, exportOptionsPath): Array { - return [ - '-exportArchive', - '-archivePath', projectName + '.xcarchive', - '-exportOptionsPlist', exportOptionsPath, - '-exportPath', outputPath - ]; + private async createIpa(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise { + let xarchivePath = await this.archive(projectData); + let exportFileIpa = await this.exportDevelopmentArchive(projectData, + buildConfig, + { + archivePath: xarchivePath, + }); + + return exportFileIpa; } public isPlatformPrepared(projectRoot: string, projectData: IProjectData): boolean { From 52eb8189964ac1776fe7fcb47cf0c3ed94d115aa Mon Sep 17 00:00:00 2001 From: Yosif Yosifov Date: Fri, 31 Mar 2017 16:02:35 +0300 Subject: [PATCH 3/4] fix lint --- lib/services/ios-project-service.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 6a628641bd..fe4fa6bf6b 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -248,8 +248,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ "-exportPath", exportPath, "-exportOptionsPlist", platformData.configurationFilePath ]; - - await this.$childProcess.spawnFromEvent("xcodebuild", args, "exit", + 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 }); @@ -458,12 +457,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ private async createIpa(projectRoot: string, projectData: IProjectData, buildConfig: IBuildConfig): Promise { let xarchivePath = await this.archive(projectData); - let exportFileIpa = await this.exportDevelopmentArchive(projectData, + let exportFileIpa = await this.exportDevelopmentArchive(projectData, buildConfig, - { - archivePath: xarchivePath, + { + archivePath: xarchivePath, }); - + return exportFileIpa; } From 11e011b4446b4f60907028cb0de30442787ba5d1 Mon Sep 17 00:00:00 2001 From: Yosif Yosifov Date: Mon, 3 Apr 2017 12:39:01 +0300 Subject: [PATCH 4/4] Make method exportDevArchive method private and set throw exceptions to true on xcodebuild --- lib/services/ios-project-service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index fe4fa6bf6b..5c5fadf64e 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -231,9 +231,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ } /** - * Exports .xcarchive for AppStore distribution. + * Exports .xcarchive for a development device. */ - public async exportDevelopmentArchive(projectData: IProjectData, buildConfig: IBuildConfig, options: { archivePath: string, exportDir?: string, teamID?: string }): Promise { + private async exportDevelopmentArchive(projectData: IProjectData, buildConfig: IBuildConfig, options: { archivePath: string, exportDir?: string, teamID?: string }): Promise { let platformData = this.getPlatformData(projectData); let projectRoot = platformData.projectRoot; let archivePath = options.archivePath; @@ -250,7 +250,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ ]; 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 }); + { emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true }); return exportFile; }