microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/ios/iOSPlatform.ts
454lines · modeblame
8a67e140Artem Egorov8 years ago | 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"; | |
df8c800dArtem Egorov8 years ago | 5 | import * as semver from "semver"; |
8a67e140Artem Egorov8 years ago | 6 | |
09f6024fHeniker4 years ago | 7 | import * as nls from "vscode-nls"; |
34472878RedMickey5 years ago | 8 | import { ChildProcess } from "../../common/node/childProcess"; |
| 9 | import { CommandExecutor } from "../../common/commandExecutor"; | |
4cd25962JiglioNero4 years ago | 10 | import { MobilePlatformDeps, TargetType } from "../generalPlatform"; |
34472878RedMickey5 years ago | 11 | import { IIOSRunOptions, PlatformType } from "../launchArgs"; |
| 12 | import { OutputVerifier, PatternToFailure } from "../../common/outputVerifier"; | |
| 13 | import { TelemetryHelper } from "../../common/telemetryHelper"; | |
fc602bb6Yuri Skorokhodov7 years ago | 14 | import { InternalErrorCode } from "../../common/error/internalErrorCode"; |
7e74daf7Yuri Skorokhodov6 years ago | 15 | import { AppLauncher } from "../appLauncher"; |
4cd25962JiglioNero4 years ago | 16 | import { GeneralMobilePlatform } from "../generalMobilePlatform"; |
| 17 | import { ErrorHelper } from "../../common/error/errorHelper"; | |
47927908RedMickey4 years ago | 18 | import { ProjectVersionHelper } from "../../common/projectVersionHelper"; |
09f6024fHeniker4 years ago | 19 | import { IDebuggableIOSTarget, IOSTarget, IOSTargetManager } from "./iOSTargetManager"; |
| 20 | import { IOSDebugModeManager } from "./iOSDebugModeManager"; | |
| 21 | import { PlistBuddy } from "./plistBuddy"; | |
| 22 | | |
34472878RedMickey5 years ago | 23 | nls.config({ |
| 24 | messageFormat: nls.MessageFormat.bundle, | |
| 25 | bundleFormat: nls.BundleFormat.standalone, | |
| 26 | })(); | |
d7d405aeYuri Skorokhodov7 years ago | 27 | const localize = nls.loadMessageBundle(); |
8022afdfVladimir Kotikov8 years ago | 28 | |
8a67e140Artem Egorov8 years ago | 29 | export class IOSPlatform extends GeneralMobilePlatform { |
| 30 | public static DEFAULT_IOS_PROJECT_RELATIVE_PATH = "ios"; | |
0a68f8dbArtem Egorov8 years ago | 31 | |
47927908RedMickey4 years ago | 32 | private static readonly NEW_RN_CLI_BEHAVIOUR_VERSION = "0.60.0"; |
| 33 | | |
8a67e140Artem Egorov8 years ago | 34 | private plistBuddy = new PlistBuddy(); |
0db0be15Artem Egorov8 years ago | 35 | private iosProjectRoot: string; |
7daed3fcArtem Egorov8 years ago | 36 | private iosDebugModeManager: IOSDebugModeManager; |
| 37 | | |
db6fd42aRuslan Bikkinin7 years ago | 38 | private defaultConfiguration: string = "Debug"; |
| 39 | private configurationArgumentName: string = "--configuration"; | |
8a67e140Artem Egorov8 years ago | 40 | |
4cd25962JiglioNero4 years ago | 41 | protected target?: IOSTarget; |
| 42 | | |
0a68f8dbArtem Egorov8 years ago | 43 | // We should add the common iOS build/run errors we find to this list |
34472878RedMickey5 years ago | 44 | private static RUN_IOS_FAILURE_PATTERNS: PatternToFailure[] = [ |
| 45 | { | |
| 46 | pattern: "No devices are booted", | |
| 47 | errorCode: InternalErrorCode.IOSSimulatorNotLaunchable, | |
| 48 | }, | |
| 49 | { | |
| 50 | pattern: "FBSOpenApplicationErrorDomain", | |
| 51 | errorCode: InternalErrorCode.IOSSimulatorNotLaunchable, | |
| 52 | }, | |
| 53 | { | |
| 54 | pattern: "ios-deploy", | |
| 55 | errorCode: InternalErrorCode.IOSDeployNotFound, | |
| 56 | }, | |
| 57 | ]; | |
8a67e140Artem Egorov8 years ago | 58 | |
9fbbf669RedMickey4 years ago | 59 | private static readonly RUN_IOS_SUCCESS_PATTERNS = [ |
| 60 | "BUILD SUCCEEDED|success Successfully built the app", | |
| 61 | ]; | |
8a67e140Artem Egorov8 years ago | 62 | |
0a68f8dbArtem Egorov8 years ago | 63 | constructor(protected runOptions: IIOSRunOptions, platformDeps: MobilePlatformDeps = {}) { |
| 64 | super(runOptions, platformDeps); | |
8a67e140Artem Egorov8 years ago | 65 | |
4cd25962JiglioNero4 years ago | 66 | this.targetManager = new IOSTargetManager(); |
db6fd42aRuslan Bikkinin7 years ago | 67 | this.runOptions.configuration = this.getConfiguration(); |
| 68 | | |
34472878RedMickey5 years ago | 69 | const iosProjectFolderPath = IOSPlatform.getOptFromRunArgs( |
| 70 | this.runArguments, | |
| 71 | "--project-path", | |
| 72 | false, | |
| 73 | ); | |
| 74 | this.iosProjectRoot = path.join( | |
| 75 | this.projectPath, | |
14a3206cConnorQi011 months ago | 76 | iosProjectFolderPath || IOSPlatform.DEFAULT_IOS_PROJECT_RELATIVE_PATH, |
34472878RedMickey5 years ago | 77 | ); |
116c3cb0Ruslan Bikkinin7 years ago | 78 | const schemeFromArgs = IOSPlatform.getOptFromRunArgs(this.runArguments, "--scheme", false); |
34472878RedMickey5 years ago | 79 | this.iosDebugModeManager = new IOSDebugModeManager( |
| 80 | this.iosProjectRoot, | |
| 81 | this.projectPath, | |
| 82 | schemeFromArgs ? schemeFromArgs : this.runOptions.scheme, | |
| 83 | ); | |
4cd25962JiglioNero4 years ago | 84 | } |
8a67e140Artem Egorov8 years ago | 85 | |
4cd25962JiglioNero4 years ago | 86 | public async getTarget(): Promise<IOSTarget> { |
| 87 | if (!this.target) { | |
| 88 | const targetFromRunArgs = await this.getTargetFromRunArgs(); | |
| 89 | if (targetFromRunArgs) { | |
| 90 | this.target = targetFromRunArgs; | |
| 91 | } else { | |
09f6024fHeniker4 years ago | 92 | const targets = |
| 93 | (await this.targetManager.getTargetList()) as IDebuggableIOSTarget[]; | |
4cd25962JiglioNero4 years ago | 94 | const targetsBySpecifiedType = targets.filter(target => { |
| 95 | switch (this.runOptions.target) { | |
| 96 | case TargetType.Simulator: | |
| 97 | return target.isVirtualTarget; | |
| 98 | case TargetType.Device: | |
| 99 | return !target.isVirtualTarget; | |
| 100 | case undefined: | |
| 101 | case "": | |
| 102 | return true; | |
| 103 | default: | |
| 104 | return ( | |
| 105 | target.id === this.runOptions.target || | |
| 106 | target.name === this.runOptions.target | |
| 107 | ); | |
| 108 | } | |
| 109 | }); | |
| 110 | if (targetsBySpecifiedType.length) { | |
| 111 | this.target = IOSTarget.fromInterface(targetsBySpecifiedType[0]); | |
| 112 | } else if (targets.length) { | |
| 113 | this.logger.warning( | |
| 114 | localize( | |
| 115 | "ThereIsNoTargetWithSpecifiedTargetType", | |
| 116 | "There is no any target with specified target type '{0}'. Continue with any target.", | |
| 117 | this.runOptions.target, | |
| 118 | ), | |
| 119 | ); | |
| 120 | this.target = IOSTarget.fromInterface(targets[0]); | |
| 121 | } else { | |
| 122 | throw ErrorHelper.getInternalError( | |
| 123 | InternalErrorCode.IOSThereIsNoAnyDebuggableTarget, | |
| 124 | ); | |
| 125 | } | |
| 126 | } | |
8022afdfVladimir Kotikov8 years ago | 127 | } |
4cd25962JiglioNero4 years ago | 128 | return this.target; |
| 129 | } | |
0db0be15Artem Egorov8 years ago | 130 | |
4cd25962JiglioNero4 years ago | 131 | public async showDevMenu(appLauncher: AppLauncher): Promise<void> { |
| 132 | const worker = appLauncher.getAppWorker(); | |
| 133 | if (worker) { | |
| 134 | worker.showDevMenuCommand(); | |
8a67e140Artem Egorov8 years ago | 135 | } |
| 136 | } | |
| 137 | | |
4cd25962JiglioNero4 years ago | 138 | public async reloadApp(appLauncher: AppLauncher): Promise<void> { |
| 139 | const worker = appLauncher.getAppWorker(); | |
| 140 | if (worker) { | |
| 141 | worker.reloadAppCommand(); | |
119d7878JiglioNero5 years ago | 142 | } |
| 143 | } | |
| 144 | | |
0d77292aJiglioNero4 years ago | 145 | public async runApp(): Promise<void> { |
e7a2c40dRedMickey4 years ago | 146 | let extProps: any = { |
031832ffArtem Egorov8 years ago | 147 | platform: { |
259c018fYuri Skorokhodov5 years ago | 148 | value: PlatformType.iOS, |
031832ffArtem Egorov8 years ago | 149 | isPii: false, |
| 150 | }, | |
| 151 | }; | |
| 152 | | |
e7a2c40dRedMickey4 years ago | 153 | if (this.runOptions.isDirect) { |
| 154 | extProps.isDirect = { | |
| 155 | value: true, | |
| 156 | isPii: false, | |
| 157 | }; | |
| 158 | this.projectObserver?.updateRNIosHermesProjectState(true); | |
| 159 | } | |
| 160 | | |
34472878RedMickey5 years ago | 161 | extProps = TelemetryHelper.addPlatformPropertiesToTelemetryProperties( |
| 162 | this.runOptions, | |
| 163 | this.runOptions.reactNativeVersions, | |
| 164 | extProps, | |
| 165 | ); | |
ba953e9fRedMickey6 years ago | 166 | |
0d77292aJiglioNero4 years ago | 167 | await TelemetryHelper.generate("iOSPlatform.runApp", extProps, async () => { |
031832ffArtem Egorov8 years ago | 168 | // Compile, deploy, and launch the app on either a simulator or a device |
34472878RedMickey5 years ago | 169 | const env = GeneralMobilePlatform.getEnvArgument( |
| 170 | process.env, | |
| 171 | this.runOptions.env, | |
| 172 | this.runOptions.envFile, | |
| 173 | ); | |
| 174 | | |
| 175 | if ( | |
| 176 | !semver.valid( | |
| 177 | this.runOptions.reactNativeVersions.reactNativeVersion, | |
09f6024fHeniker4 years ago | 178 | ) /* Custom RN implementations should support this flag*/ || |
34472878RedMickey5 years ago | 179 | semver.gte( |
| 180 | this.runOptions.reactNativeVersions.reactNativeVersion, | |
| 181 | IOSPlatform.NO_PACKAGER_VERSION, | |
47927908RedMickey4 years ago | 182 | ) || |
| 183 | ProjectVersionHelper.isCanaryVersion( | |
| 184 | this.runOptions.reactNativeVersions.reactNativeVersion, | |
34472878RedMickey5 years ago | 185 | ) |
| 186 | ) { | |
7fa90b3bRedMickey6 years ago | 187 | this.runArguments.push("--no-packager"); |
| 188 | } | |
| 189 | // Since @react-native-community/cli@2.1.0 build output are hidden by default | |
| 190 | // we are using `--verbose` to show it as it contains `BUILD SUCCESSFUL` and other patterns | |
47927908RedMickey4 years ago | 191 | if ( |
| 192 | semver.gte( | |
| 193 | this.runOptions.reactNativeVersions.reactNativeVersion, | |
| 194 | IOSPlatform.NEW_RN_CLI_BEHAVIOUR_VERSION, | |
| 195 | ) || | |
| 196 | ProjectVersionHelper.isCanaryVersion( | |
| 197 | this.runOptions.reactNativeVersions.reactNativeVersion, | |
| 198 | ) | |
| 199 | ) { | |
7fa90b3bRedMickey6 years ago | 200 | this.runArguments.push("--verbose"); |
| 201 | } | |
34472878RedMickey5 years ago | 202 | const runIosSpawn = new CommandExecutor( |
4dfb1c4cetatanova5 years ago | 203 | this.runOptions.nodeModulesRoot, |
34472878RedMickey5 years ago | 204 | this.projectPath, |
| 205 | this.logger, | |
| 206 | ).spawnReactCommand("run-ios", this.runArguments, { env }); | |
0d77292aJiglioNero4 years ago | 207 | await new OutputVerifier( |
ce5e88eeYuri Skorokhodov5 years ago | 208 | () => |
34472878RedMickey5 years ago | 209 | this.generateSuccessPatterns( |
| 210 | this.runOptions.reactNativeVersions.reactNativeVersion, | |
| 211 | ), | |
| 212 | () => Promise.resolve(IOSPlatform.RUN_IOS_FAILURE_PATTERNS), | |
| 213 | PlatformType.iOS, | |
| 214 | ).process(runIosSpawn); | |
80dcd561ConnorQi013 months ago | 215 | |
1a12db81ConnorQi3 months ago | 216 | // Save target info for status indicator |
80dcd561ConnorQi013 months ago | 217 | if (!this.target) { |
1a12db81ConnorQi3 months ago | 218 | const target = await this.getTarget(); |
| 219 | if (target && target.name) { | |
| 220 | this.target = new IOSTarget( | |
| 221 | target.isOnline, | |
| 222 | target.isVirtualTarget, | |
| 223 | target.id, | |
| 224 | target.name, | |
| 225 | target.system, | |
| 226 | ); | |
| 227 | } | |
80dcd561ConnorQi013 months ago | 228 | } |
031832ffArtem Egorov8 years ago | 229 | }); |
8a67e140Artem Egorov8 years ago | 230 | } |
| 231 | | |
0d77292aJiglioNero4 years ago | 232 | public async enableJSDebuggingMode(): Promise<void> { |
8a67e140Artem Egorov8 years ago | 233 | // Configure the app for debugging |
4cd25962JiglioNero4 years ago | 234 | if (!(await this.getTarget()).isVirtualTarget) { |
8a67e140Artem Egorov8 years ago | 235 | // Note that currently we cannot automatically switch the device into debug mode. |
34472878RedMickey5 years ago | 236 | this.logger.info( |
| 237 | "Application is running on a device, please shake device and select 'Debug JS Remotely' to enable debugging.", | |
| 238 | ); | |
0d77292aJiglioNero4 years ago | 239 | return; |
8a67e140Artem Egorov8 years ago | 240 | } |
| 241 | | |
| 242 | // Wait until the configuration file exists, and check to see if debugging is enabled | |
0d77292aJiglioNero4 years ago | 243 | const [debugModeEnabled, bundleId] = await Promise.all<boolean | string>([ |
1c2424f4RedMickey5 years ago | 244 | this.iosDebugModeManager.getAppRemoteDebuggingSetting( |
34472878RedMickey5 years ago | 245 | this.runOptions.configuration, |
| 246 | this.runOptions.productName, | |
| 247 | ), | |
8a67e140Artem Egorov8 years ago | 248 | this.getBundleId(), |
0d77292aJiglioNero4 years ago | 249 | ]); |
| 250 | if (debugModeEnabled) { | |
| 251 | return; | |
| 252 | } | |
| 253 | // Debugging must still be enabled | |
| 254 | // We enable debugging by writing to a plist file that backs a NSUserDefaults object, | |
| 255 | // but that file is written to by the app on occasion. To avoid races, we shut the app | |
| 256 | // down before writing to the file. | |
| 257 | const childProcess = new ChildProcess(); | |
| 258 | const output = await childProcess.execToString("xcrun simctl spawn booted launchctl list"); | |
| 259 | // Try to find an entry that looks like UIKitApplication:com.example.myApp[0x4f37] | |
09f6024fHeniker4 years ago | 260 | const regex = new RegExp(`(\\S+${String(bundleId)}\\S+)`); |
0d77292aJiglioNero4 years ago | 261 | const match = regex.exec(output); |
| 262 | // If we don't find a match, the app must not be running and so we do not need to close it | |
| 263 | if (match) { | |
| 264 | await childProcess.exec(`xcrun simctl spawn booted launchctl stop ${match[1]}`); | |
| 265 | } | |
| 266 | // Write to the settings file while the app is not running to avoid races | |
| 267 | await this.iosDebugModeManager.setAppRemoteDebuggingSetting( | |
09f6024fHeniker4 years ago | 268 | /* enable=*/ true, |
0d77292aJiglioNero4 years ago | 269 | this.runOptions.configuration, |
| 270 | this.runOptions.productName, | |
| 271 | ); | |
| 272 | // Relaunch the app | |
| 273 | return await this.runApp(); | |
8a67e140Artem Egorov8 years ago | 274 | } |
| 275 | | |
0d77292aJiglioNero4 years ago | 276 | public async disableJSDebuggingMode(): Promise<void> { |
4cd25962JiglioNero4 years ago | 277 | if (!(await this.getTarget()).isVirtualTarget) { |
0d77292aJiglioNero4 years ago | 278 | return; |
c73f53cbJiglioNero5 years ago | 279 | } |
1c2424f4RedMickey5 years ago | 280 | return this.iosDebugModeManager.setAppRemoteDebuggingSetting( |
09f6024fHeniker4 years ago | 281 | /* enable=*/ false, |
34472878RedMickey5 years ago | 282 | this.runOptions.configuration, |
| 283 | this.runOptions.productName, | |
| 284 | ); | |
0a68f8dbArtem Egorov8 years ago | 285 | } |
| 286 | | |
ce5e88eeYuri Skorokhodov5 years ago | 287 | public prewarmBundleCache(): Promise<void> { |
259c018fYuri Skorokhodov5 years ago | 288 | return this.packager.prewarmBundleCache(PlatformType.iOS); |
8a67e140Artem Egorov8 years ago | 289 | } |
| 290 | | |
cbc7ac5bArtem Egorov7 years ago | 291 | public getRunArguments(): string[] { |
8a67e140Artem Egorov8 years ago | 292 | let runArguments: string[] = []; |
0db0be15Artem Egorov8 years ago | 293 | |
| 294 | if (this.runOptions.runArguments && this.runOptions.runArguments.length > 0) { | |
b57ea017Artem Egorov8 years ago | 295 | runArguments = this.runOptions.runArguments; |
116c3cb0Ruslan Bikkinin7 years ago | 296 | if (this.runOptions.scheme) { |
34472878RedMickey5 years ago | 297 | const schemeFromArgs = IOSPlatform.getOptFromRunArgs( |
| 298 | runArguments, | |
| 299 | "--scheme", | |
| 300 | false, | |
| 301 | ); | |
116c3cb0Ruslan Bikkinin7 years ago | 302 | if (!schemeFromArgs) { |
| 303 | runArguments.push("--scheme", this.runOptions.scheme); | |
| 304 | } else { | |
34472878RedMickey5 years ago | 305 | this.logger.warning( |
| 306 | localize( | |
| 307 | "iosSchemeParameterAlreadySetInRunArguments", | |
| 308 | "'--scheme' is set as 'runArguments' configuration parameter value, 'scheme' configuration parameter value will be omitted", | |
| 309 | ), | |
| 310 | ); | |
116c3cb0Ruslan Bikkinin7 years ago | 311 | } |
| 312 | } | |
b57ea017Artem Egorov8 years ago | 313 | } else { |
| 314 | if (this.runOptions.target) { | |
de838bbfJiglioNero6 years ago | 315 | runArguments.push(...this.handleTargetArg(this.runOptions.target)); |
b57ea017Artem Egorov8 years ago | 316 | } |
8abbd163Artem Egorov8 years ago | 317 | |
b57ea017Artem Egorov8 years ago | 318 | // provide any defined scheme |
| 319 | if (this.runOptions.scheme) { | |
| 320 | runArguments.push("--scheme", this.runOptions.scheme); | |
| 321 | } | |
8a67e140Artem Egorov8 years ago | 322 | } |
| 323 | | |
| 324 | return runArguments; | |
| 325 | } | |
| 326 | | |
4cd25962JiglioNero4 years ago | 327 | public async getTargetFromRunArgs(): Promise<IOSTarget | undefined> { |
| 328 | if (this.runOptions.runArguments && this.runOptions.runArguments.length > 0) { | |
c76b733bJiglioNero4 years ago | 329 | const targets = (await this.targetManager.getTargetList()) as IDebuggableIOSTarget[]; |
| 330 | | |
4cd25962JiglioNero4 years ago | 331 | const udid = GeneralMobilePlatform.getOptFromRunArgs( |
| 332 | this.runOptions.runArguments, | |
| 333 | "--udid", | |
| 334 | ); | |
| 335 | if (udid) { | |
| 336 | const target = targets.find(target => target.id === udid); | |
| 337 | if (target) { | |
| 338 | return IOSTarget.fromInterface(target); | |
| 339 | } | |
09f6024fHeniker4 years ago | 340 | this.logger.warning( |
| 341 | localize( | |
| 342 | "ThereIsNoIosTargetWithSuchUdid", | |
| 343 | "There is no iOS target with such UDID: {0}", | |
| 344 | udid, | |
| 345 | ), | |
| 346 | ); | |
4cd25962JiglioNero4 years ago | 347 | } |
| 348 | | |
| 349 | const device = GeneralMobilePlatform.getOptFromRunArgs( | |
| 350 | this.runOptions.runArguments, | |
| 351 | "--device", | |
| 352 | ); | |
| 353 | if (device) { | |
| 354 | const target = targets.find( | |
c76b733bJiglioNero4 years ago | 355 | target => !target.isVirtualTarget && target.name === device, |
4cd25962JiglioNero4 years ago | 356 | ); |
| 357 | if (target) { | |
| 358 | return IOSTarget.fromInterface(target); | |
| 359 | } | |
09f6024fHeniker4 years ago | 360 | this.logger.warning( |
| 361 | localize( | |
| 362 | "ThereIsNoIosDeviceWithSuchName", | |
| 363 | "There is no iOS device with such name: {0}", | |
| 364 | device, | |
| 365 | ), | |
| 366 | ); | |
4cd25962JiglioNero4 years ago | 367 | } |
| 368 | | |
| 369 | const simulator = GeneralMobilePlatform.getOptFromRunArgs( | |
| 370 | this.runOptions.runArguments, | |
| 371 | "--simulator", | |
| 372 | ); | |
| 373 | if (simulator) { | |
| 374 | const target = targets.find( | |
c76b733bJiglioNero4 years ago | 375 | target => target.isVirtualTarget && target.name === simulator, |
4cd25962JiglioNero4 years ago | 376 | ); |
| 377 | if (target) { | |
| 378 | return IOSTarget.fromInterface(target); | |
| 379 | } | |
09f6024fHeniker4 years ago | 380 | this.logger.warning( |
| 381 | localize( | |
| 382 | "ThereIsNoIosSimulatorWithSuchName", | |
| 383 | "There is no iOS simulator with such name: {0}", | |
| 384 | simulator, | |
| 385 | ), | |
| 386 | ); | |
4cd25962JiglioNero4 years ago | 387 | } |
| 388 | } | |
| 389 | | |
| 390 | return undefined; | |
| 391 | } | |
| 392 | | |
de838bbfJiglioNero6 years ago | 393 | private handleTargetArg(target: string): string[] { |
09f6024fHeniker4 years ago | 394 | return target === TargetType.Device || target === TargetType.Simulator |
| 395 | ? [`--${target}`] | |
| 396 | : ["--udid", target]; | |
de838bbfJiglioNero6 years ago | 397 | } |
| 398 | | |
0d77292aJiglioNero4 years ago | 399 | private async generateSuccessPatterns(version: string): Promise<string[]> { |
3021756bYuri Skorokhodov7 years ago | 400 | // Clone RUN_IOS_SUCCESS_PATTERNS to avoid its runtime mutation |
09f6024fHeniker4 years ago | 401 | const successPatterns = [...IOSPlatform.RUN_IOS_SUCCESS_PATTERNS]; |
4cd25962JiglioNero4 years ago | 402 | if (!(await this.getTarget()).isVirtualTarget) { |
47927908RedMickey4 years ago | 403 | if ( |
| 404 | semver.gte(version, IOSPlatform.NEW_RN_CLI_BEHAVIOUR_VERSION) || | |
| 405 | ProjectVersionHelper.isCanaryVersion(version) | |
| 406 | ) { | |
3021756bYuri Skorokhodov7 years ago | 407 | successPatterns.push("success Installed the app on the device"); |
| 408 | } else { | |
| 409 | successPatterns.push("INSTALLATION SUCCEEDED"); | |
| 410 | } | |
0d77292aJiglioNero4 years ago | 411 | return successPatterns; |
09f6024fHeniker4 years ago | 412 | } |
| 413 | const bundleId = await this.getBundleId(); | |
47927908RedMickey4 years ago | 414 | if ( |
| 415 | semver.gte(version, IOSPlatform.NEW_RN_CLI_BEHAVIOUR_VERSION) || | |
| 416 | ProjectVersionHelper.isCanaryVersion(version) | |
| 417 | ) { | |
cf6a88fclexie0112 years ago | 418 | successPatterns.push(`Launching "${bundleId}"\nsuccess Successfully launched the app`); |
3021756bYuri Skorokhodov7 years ago | 419 | } else { |
09f6024fHeniker4 years ago | 420 | successPatterns.push(`Launching ${bundleId}\n${bundleId}: `); |
3021756bYuri Skorokhodov7 years ago | 421 | } |
09f6024fHeniker4 years ago | 422 | return successPatterns; |
8a67e140Artem Egorov8 years ago | 423 | } |
| 424 | | |
db6fd42aRuslan Bikkinin7 years ago | 425 | private getConfiguration(): string { |
34472878RedMickey5 years ago | 426 | return ( |
| 427 | IOSPlatform.getOptFromRunArgs(this.runArguments, this.configurationArgumentName) || | |
| 428 | this.defaultConfiguration | |
| 429 | ); | |
db6fd42aRuslan Bikkinin7 years ago | 430 | } |
| 431 | | |
ce5e88eeYuri Skorokhodov5 years ago | 432 | private getBundleId(): Promise<string> { |
116c3cb0Ruslan Bikkinin7 years ago | 433 | let scheme = this.runOptions.scheme; |
| 434 | if (!scheme) { | |
34472878RedMickey5 years ago | 435 | const schemeFromArgs = IOSPlatform.getOptFromRunArgs( |
| 436 | this.runArguments, | |
| 437 | "--scheme", | |
| 438 | false, | |
| 439 | ); | |
116c3cb0Ruslan Bikkinin7 years ago | 440 | if (schemeFromArgs) { |
| 441 | scheme = schemeFromArgs; | |
| 442 | } | |
| 443 | } | |
34472878RedMickey5 years ago | 444 | return this.plistBuddy.getBundleId( |
| 445 | this.iosProjectRoot, | |
| 446 | this.projectPath, | |
1c2424f4RedMickey5 years ago | 447 | PlatformType.iOS, |
34472878RedMickey5 years ago | 448 | true, |
| 449 | this.runOptions.configuration, | |
| 450 | this.runOptions.productName, | |
| 451 | scheme, | |
| 452 | ); | |
8a67e140Artem Egorov8 years ago | 453 | } |
| 454 | } |