microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ffdf159274093d12e32a09aafae6d0de3099bb4a

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/ios/iOSDebugModeManager.ts

92lines · modeblame

a9d96b7cdigeff10 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
1c2424f4RedMickey5 years ago4import { ApplePlatformDebugModeManager } from "../applePlatformDebugModeManager";
34472878RedMickey5 years ago5import { PlistBuddy } from "./plistBuddy";
6import { SimulatorPlist } from "./simulatorPlist";
a9d96b7cdigeff10 years ago7
1c2424f4RedMickey5 years ago8export class IOSDebugModeManager extends ApplePlatformDebugModeManager {
dbe130e4Jimmy Thomson10 years ago9public static WEBSOCKET_EXECUTOR_NAME = "RCTWebSocketExecutor";
a9d96b7cdigeff10 years ago10private static EXECUTOR_CLASS_SETTING_NAME = ":RCTDevMenu:executorClass";
de32cf1edigeff10 years ago11
1ed272e1digeff10 years ago12private simulatorPlist: SimulatorPlist;
a9d96b7cdigeff10 years ago13
764655c9Yuri Skorokhodov6 years ago14constructor(iosProjectRoot: string, projectRoot: string, scheme?: string) {
1c2424f4RedMickey5 years ago15super(iosProjectRoot, projectRoot);
a9d96b7cdigeff10 years ago16this.projectRoot = projectRoot;
1c2424f4RedMickey5 years ago17this.simulatorPlist = new SimulatorPlist(
18this.platformProjectRoot,
19this.projectRoot,
20scheme,
21);
a9d96b7cdigeff10 years ago22}
23
1c2424f4RedMickey5 years ago24public setAppRemoteDebuggingSetting(
34472878RedMickey5 years ago25enable: boolean,
26configuration?: string,
27productName?: string,
28): Promise<void> {
de32cf1edigeff10 years ago29const plistBuddy = new PlistBuddy();
30
31// Find the plistFile with the configuration setting
32// There is a race here between us checking for the plist file, and the application starting up.
1c2424f4RedMickey5 years ago33return this.findPListFileWithRetry(configuration, productName).then((plistFile: string) => {
34472878RedMickey5 years ago34// Set the executorClass to be RCTWebSocketExecutor so on the next startup it will default into debug mode
35// This is approximately equivalent to clicking the "Debug in Chrome" button
278d8e56Vladimir Kotikov8 years ago36
34472878RedMickey5 years ago37return (enable
38? plistBuddy.setPlistProperty(
39plistFile,
40IOSDebugModeManager.EXECUTOR_CLASS_SETTING_NAME,
41IOSDebugModeManager.WEBSOCKET_EXECUTOR_NAME,
42)
43: plistBuddy.deletePlistProperty(
44plistFile,
45IOSDebugModeManager.EXECUTOR_CLASS_SETTING_NAME,
46)
47).then(() =>
48plistBuddy.setPlistBooleanProperty(
49plistFile,
50IOSDebugModeManager.REMOTE_DEBUGGING_SETTING_NAME,
51enable,
52),
53);
54});
de32cf1edigeff10 years ago55}
56
1c2424f4RedMickey5 years ago57public getAppRemoteDebuggingSetting(
34472878RedMickey5 years ago58configuration?: string,
59productName?: string,
60): Promise<boolean> {
1c2424f4RedMickey5 years ago61return this.findPListFileWithRetry(configuration, productName).then((plistFile: string) => {
34472878RedMickey5 years ago62// Attempt to read from the file, but if the property is not defined then return the empty string
63return Promise.all([
64new PlistBuddy().readPlistProperty(
65plistFile,
66IOSDebugModeManager.EXECUTOR_CLASS_SETTING_NAME,
67),
68new PlistBuddy().readPlistProperty(
69plistFile,
70IOSDebugModeManager.REMOTE_DEBUGGING_SETTING_NAME,
71),
72])
73.then(([executorClassName, remoteDebugEnabled]) => {
74return (
75executorClassName === IOSDebugModeManager.WEBSOCKET_EXECUTOR_NAME &&
76remoteDebugEnabled === "true"
77);
78})
79.catch(() => false);
80});
1ed272e1digeff10 years ago81}
82
1c2424f4RedMickey5 years ago83protected tryOneAttemptToFindPListFile(
34472878RedMickey5 years ago84configuration?: string,
85productName?: string,
86): Promise<string> {
db6fd42aRuslan Bikkinin7 years ago87return this.simulatorPlist.findPlistFile(configuration, productName).catch(reason => {
0a68f8dbArtem Egorov8 years ago88this.logger.debug(`Failed one attempt to find plist file: ${reason}`);
5c8365a6Artem Egorov8 years ago89return "";
5edb6e49Digeff10 years ago90});
dbe130e4Jimmy Thomson10 years ago91}
a9d96b7cdigeff10 years ago92}