microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/ios/compiler.ts
36lines · 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 | |
| 4 | import * as path from "path"; |
| 5 | import * as Q from "q"; |
| 6 | |
| 7 | import {CommandExecutor} from "../../common/commandExecutor"; |
| 8 | import {Xcodeproj, IXcodeProjFile} from "../../common/ios/xcodeproj"; |
| 9 | |
| 10 | export class Compiler { |
| 11 | private projectRoot: string; |
| 12 | |
| 13 | constructor(projectRoot: string) { |
| 14 | this.projectRoot = projectRoot; |
| 15 | } |
| 16 | |
| 17 | public compile(): Q.Promise<void> { |
| 18 | return this.xcodeBuildArguments().then((xcodeArguments: string[]) => { |
| 19 | return new CommandExecutor(this.projectRoot).spawn("xcodebuild", xcodeArguments); |
| 20 | }); |
| 21 | } |
| 22 | |
| 23 | /* |
| 24 | Return the appropriate arguments for compiling a react native project |
| 25 | */ |
| 26 | private xcodeBuildArguments(): Q.Promise<string[]> { |
| 27 | return new Xcodeproj().findXcodeprojFile(this.projectRoot).then((projectFile: IXcodeProjFile) => { |
| 28 | return [ |
| 29 | projectFile.fileType === ".xcworkspace" ? "-workspace" : "-project", projectFile.fileName, |
| 30 | "-scheme", projectFile.projectName, |
| 31 | "-destination", "generic/platform=iOS", // Build for a generic iOS device |
| 32 | "-derivedDataPath", path.join(this.projectRoot, "build"), |
| 33 | ]; |
| 34 | }); |
| 35 | } |
| 36 | } |