Skip to content

Commit 535471f

Browse files
Merge pull request #3986 from NativeScript/vladimirov/fix-debug-commands
fix: tns debug ios command fails in some cases
2 parents 77f5cb1 + 81e26c0 commit 535471f

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

lib/common/commands/device/device-log-stream.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { IOS_LOG_PREDICATE } from "../../constants";
2-
31
export class OpenDeviceLogStreamCommand implements ICommand {
42
private static NOT_SPECIFIED_DEVICE_ERROR_MESSAGE = "More than one device found. Specify device explicitly.";
53

@@ -25,7 +23,7 @@ export class OpenDeviceLogStreamCommand implements ICommand {
2523
this.$errors.fail(OpenDeviceLogStreamCommand.NOT_SPECIFIED_DEVICE_ERROR_MESSAGE);
2624
}
2725

28-
const action = (device: Mobile.IiOSDevice) => device.openDeviceLogStream({predicate: IOS_LOG_PREDICATE});
26+
const action = (device: Mobile.IiOSDevice) => device.openDeviceLogStream();
2927
await this.$devicesService.execute(action);
3028
}
3129
}

lib/common/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export async function connectEventuallyUntilTimeout(factory: () => Promise<net.S
470470
const connectionTimer = setTimeout(function () {
471471
if (!isResolved) {
472472
isResolved = true;
473-
reject(lastKnownError);
473+
reject(lastKnownError || new Error(`Unable to connect for ${timeout}ms`));
474474
}
475475
}, timeout);
476476

lib/common/mobile/ios/simulator/ios-simulator-device.ts

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export class IOSSimulator implements Mobile.IiOSSimulator {
5555

5656
@cache()
5757
public async openDeviceLogStream(options?: Mobile.IiOSLogStreamOptions): Promise<void> {
58+
options = options || {};
59+
options.predicate = options.hasOwnProperty("predicate") ? options.predicate : constants.IOS_LOG_PREDICATE;
5860
return this.$iOSSimulatorLogProvider.startLogProcess(this.simulator.id, options);
5961
}
6062
}

lib/services/ios-debug-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from "path";
44
import * as log4js from "log4js";
55
import { ChildProcess } from "child_process";
66
import { DebugServiceBase } from "./debug-service-base";
7+
import { IOS_LOG_PREDICATE } from "../common/constants";
78
import { CONNECTION_ERROR_EVENT_NAME, AWAIT_NOTIFICATION_TIMEOUT_SECONDS } from "../constants";
89
import { getPidFromiOSSimulatorLogs } from "../common/helpers";
910
const inspectorAppName = "NativeScript Inspector.app";
@@ -15,7 +16,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
1516
private _sockets: net.Socket[] = [];
1617
private _socketProxy: any;
1718

18-
constructor(protected device: Mobile.IDevice,
19+
constructor(protected device: Mobile.IiOSDevice,
1920
protected $devicesService: Mobile.IDevicesService,
2021
private $platformService: IPlatformService,
2122
private $iOSEmulatorServices: Mobile.IiOSSimulatorService,
@@ -60,7 +61,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
6061
this.$deviceLogProvider.setProjectNameForDevice(debugData.deviceIdentifier, projectName);
6162
}
6263

63-
await this.device.openDeviceLogStream();
64+
await this.device.openDeviceLogStream({ predicate: IOS_LOG_PREDICATE });
6465
}
6566

6667
await this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(this.device, debugData, debugOptions);

npm-shrinkwrap.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"inquirer": "6.2.0",
4545
"ios-device-lib": "0.4.15",
4646
"ios-mobileprovision-finder": "1.0.10",
47-
"ios-sim-portable": "4.0.3",
47+
"ios-sim-portable": "4.0.4",
4848
"istextorbinary": "2.2.1",
4949
"jimp": "0.2.28",
5050
"lockfile": "1.0.3",

0 commit comments

Comments
 (0)