microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
f8d3243916133136da9c1d8eedef7428db609d7d

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/debugger/ios/compiler.ts

42lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import * as path from "path";
5import * as Q from "q";
6
7import {CommandExecutor} from "../../utils/commands/commandExecutor";
8import {Xcodeproj} from "./xcodeproj";
9
10export class Compiler {
11 private projectRoot: string;
12 private simulator: boolean;
13
14 constructor(projectRoot: string, simulator: boolean) {
15 this.projectRoot = projectRoot;
16 this.simulator = simulator;
17 }
18
19 public compile(): Q.Promise<void> {
20 return this.xcodeBuildArguments().then((xcodeArguments: string[]) => {
21 return new CommandExecutor(this.projectRoot).spawnAndWaitForCompletion("xcodebuild", xcodeArguments);
22 });
23 }
24
25 /*
26 Return the appropriate arguments for compiling a react native project
27 */
28 private xcodeBuildArguments(): Q.Promise<string[]> {
29 if (this.simulator) {
30 return Q.reject<string[]>(new Error("Error: Compiling for simulator; should be using 'react-native run-ios' instead"));
31 }
32 return new Xcodeproj().findXcodeprojFile(this.projectRoot).then((projectFile: string) => {
33 const projectName = path.basename(projectFile, path.extname(projectFile));
34 return [
35 "-project", path.join(this.projectRoot, "ios", projectFile),
36 "-scheme", projectName,
37 "-destination", "generic/platform=iOS", // Build for a generic iOS device
38 "-derivedDataPath", path.join(this.projectRoot, "ios", "build")
39 ];
40 });
41 }
42}