Skip to content

Commit 9d52f93

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #45 from telerik/fatme/show-application-output
Show application output
2 parents 399eb94 + 0c9eb7a commit 9d52f93

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

lib/declarations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface IDevice {
2727
}
2828

2929
interface ISimctl {
30-
launch(deviceId: string, applicationIdentifier: string): IFuture<void>;
30+
launch(deviceId: string, applicationIdentifier: string): IFuture<string>;
3131
install(deviceId: string, applicationPath: string): IFuture<void>;
3232
uninstall(deviceId: string, applicationIdentifier: string): IFuture<void>;
3333
notifyPost(deviceId: string, notification: string): IFuture<void>;

lib/iphone-simulator-xcode-7.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import util = require("util");
1111
import utils = require("./utils");
1212
import xcode = require("./xcode");
1313
var $ = require("NodObjC");
14+
var osenv = require("osenv");
1415

1516
export class XCode7Simulator implements ISimulator {
1617
private static DEVICE_IDENTIFIER_PREFIX = "com.apple.CoreSimulator.SimDeviceType";
@@ -55,7 +56,31 @@ export class XCode7Simulator implements ISimulator {
5556
}
5657

5758
this.simctl.install(device.id, applicationPath).wait();
58-
this.simctl.launch(device.id, applicationIdentifier).wait();
59+
let launchResult = this.simctl.launch(device.id, applicationIdentifier).wait();
60+
61+
if (options.logging) {
62+
let pid = launchResult.split(":")[1].trim();
63+
let logFilePath = path.join(osenv.home(), "Library", "Logs", "CoreSimulator", device.id, "system.log");
64+
65+
let childProcess = require("child_process").spawn("tail", ['-f', '-n', '1', logFilePath]);
66+
if(childProcess.stdout) {
67+
childProcess.stdout.on("data", (data: NodeBuffer) => {
68+
let dataAsString = data.toString();
69+
if (dataAsString.indexOf(`[${pid}]`) > -1) {
70+
console.log(dataAsString);
71+
}
72+
});
73+
}
74+
75+
if(childProcess.stderr) {
76+
childProcess.stderr.on("data", (data: string) => {
77+
let dataAsString = data.toString();
78+
if (dataAsString.indexOf(`[${pid}]`) > -1) {
79+
console.error(dataAsString);
80+
}
81+
});
82+
}
83+
}
5984
}).future<void>()();
6085
}
6186

lib/simctl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import options = require("./options");
88

99
export class Simctl implements ISimctl {
1010

11-
public launch(deviceId: string, applicationIdentifier: string): IFuture<void> {
11+
public launch(deviceId: string, applicationIdentifier: string): IFuture<string> {
1212
let args: string[] = [];
13-
if(options.waitForDebugger) {
13+
if (options.waitForDebugger) {
1414
args.push("-w");
1515
}
1616

0 commit comments

Comments
 (0)