@@ -11,6 +11,7 @@ import util = require("util");
11
11
import utils = require( "./utils" ) ;
12
12
import xcode = require( "./xcode" ) ;
13
13
var $ = require ( "NodObjC" ) ;
14
+ var osenv = require ( "osenv" ) ;
14
15
15
16
export class XCode7Simulator implements ISimulator {
16
17
private static DEVICE_IDENTIFIER_PREFIX = "com.apple.CoreSimulator.SimDeviceType" ;
@@ -55,7 +56,31 @@ export class XCode7Simulator implements ISimulator {
55
56
}
56
57
57
58
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
+ }
59
84
} ) . future < void > ( ) ( ) ;
60
85
}
61
86
0 commit comments