microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
70f7cae4a697f9868d22dfdd08089a2cd2076772

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/debugger/ios/compiler.ts

36lines · modepreview

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

import * as path from "path";
import * as Q from "q";

import {CommandExecutor} from "../../common/commandExecutor";
import {Xcodeproj, IXcodeProjFile} from "../../common/ios/xcodeproj";

export class Compiler {
    private projectRoot: string;

    constructor(projectRoot: string) {
        this.projectRoot = projectRoot;
    }

    public compile(): Q.Promise<void> {
        return this.xcodeBuildArguments().then((xcodeArguments: string[]) => {
            return new CommandExecutor(this.projectRoot).spawn("xcodebuild", xcodeArguments);
        });
    }

    /*
        Return the appropriate arguments for compiling a react native project
    */
    private xcodeBuildArguments(): Q.Promise<string[]> {
        return new Xcodeproj().findXcodeprojFile(this.projectRoot).then((projectFile: IXcodeProjFile) => {
            return [
                projectFile.fileType === ".xcworkspace" ? "-workspace" : "-project", projectFile.fileName,
                "-scheme", projectFile.projectName,
                "-destination", "generic/platform=iOS", // Build for a generic iOS device
                "-derivedDataPath", path.join(this.projectRoot, "build"),
            ];
        });
    }
}