-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathxcodebuild-service.ts
58 lines (49 loc) · 3.15 KB
/
xcodebuild-service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as path from "path";
export class XcodebuildService implements IXcodebuildService {
constructor(
private $exportOptionsPlistService: IExportOptionsPlistService,
private $xcodebuildArgsService: IXcodebuildArgsService,
private $xcodebuildCommandService: IXcodebuildCommandService
) { }
public async buildForDevice(platformData: IPlatformData, projectData: IProjectData, buildConfig: IBuildConfig): Promise<string> {
const args = await this.$xcodebuildArgsService.getBuildForDeviceArgs(platformData, projectData, buildConfig);
await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot, stdio: buildConfig && buildConfig.buildOutputStdio });
const archivePath = await this.createDevelopmentArchive(platformData, projectData, buildConfig);
return archivePath;
}
public async buildForSimulator(platformData: IPlatformData, projectData: IProjectData, buildConfig: IBuildConfig): Promise<void> {
const args = await this.$xcodebuildArgsService.getBuildForSimulatorArgs(platformData, projectData, buildConfig);
await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot, stdio: buildConfig.buildOutputStdio });
}
public async buildForAppStore(platformData: IPlatformData, projectData: IProjectData, buildConfig: IBuildConfig): Promise<string> {
const args = await this.$xcodebuildArgsService.getBuildForDeviceArgs(platformData, projectData, buildConfig);
await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot, stdio: buildConfig && buildConfig.buildOutputStdio });
const archivePath = await this.createDistributionArchive(platformData, projectData, buildConfig);
return archivePath;
}
private async createDevelopmentArchive(platformData: IPlatformData, projectData: IProjectData, buildConfig: IBuildConfig): Promise<string> {
const archivePath = path.join(platformData.getBuildOutputPath(buildConfig), projectData.projectName + ".xcarchive");
const output = await this.$exportOptionsPlistService.createDevelopmentExportOptionsPlist(archivePath, projectData, buildConfig);
const args = [
"-exportArchive",
"-archivePath", archivePath,
"-exportPath", output.exportFileDir,
"-exportOptionsPlist", output.exportOptionsPlistFilePath
];
await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot, stdio: buildConfig.buildOutputStdio });
return output.exportFilePath;
}
private async createDistributionArchive(platformData: IPlatformData, projectData: IProjectData, buildConfig: IBuildConfig): Promise<string> {
const archivePath = path.join(platformData.getBuildOutputPath(buildConfig), projectData.projectName + ".xcarchive");
const output = await this.$exportOptionsPlistService.createDistributionExportOptionsPlist(archivePath, projectData, buildConfig);
const args = [
"-exportArchive",
"-archivePath", archivePath,
"-exportPath", output.exportFileDir,
"-exportOptionsPlist", output.exportOptionsPlistFilePath
];
await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot });
return output.exportFilePath;
}
}
$injector.register("xcodebuildService", XcodebuildService);