@@ -4,9 +4,9 @@ import {spawnSync} from 'child_process';
4
4
import os from 'os' ;
5
5
import path from 'path' ;
6
6
import getSimulators from '../../tools/getSimulators' ;
7
- import listDevices from '../../tools/listDevices' ;
7
+ import listDevices , { stripPlatform } from '../../tools/listDevices' ;
8
8
import { getPlatformInfo } from '../runCommand/getPlatformInfo' ;
9
- import { BuilderCommand } from '../../types' ;
9
+ import { BuilderCommand , Device } from '../../types' ;
10
10
import { supportedPlatforms } from '../../config/supportedPlatforms' ;
11
11
import { promptForDeviceToTailLogs } from '../../tools/prompts' ;
12
12
@@ -50,12 +50,14 @@ const createLog =
50
50
return ;
51
51
}
52
52
53
- const bootedAndAvailableSimulators = bootedSimulators . map ( ( booted ) => {
54
- const available = availableSimulators . find (
55
- ( { udid} ) => udid === booted . udid ,
56
- ) ;
57
- return { ...available , ...booted } ;
58
- } ) ;
53
+ const bootedAndAvailableSimulators = bootedSimulators
54
+ . map ( ( booted ) => {
55
+ const available = availableSimulators . find (
56
+ ( { udid} ) => udid === booted . udid ,
57
+ ) ;
58
+ return { ...available , ...booted } ;
59
+ } )
60
+ . filter ( ( { sdk} ) => sdk && sdkNames . includes ( stripPlatform ( sdk ) ) ) ;
59
61
60
62
if ( bootedAndAvailableSimulators . length === 0 ) {
61
63
logger . error (
@@ -70,22 +72,34 @@ const createLog =
70
72
bootedAndAvailableSimulators ,
71
73
) ;
72
74
73
- tailDeviceLogs ( udid ) ;
75
+ const simulator = bootedAndAvailableSimulators . find (
76
+ ( { udid : deviceUDID } ) => deviceUDID === udid ,
77
+ ) ;
78
+
79
+ if ( ! simulator ) {
80
+ throw new CLIError (
81
+ `Unable to find simulator with udid: ${ udid } in booted simulators` ,
82
+ ) ;
83
+ }
84
+
85
+ tailDeviceLogs ( simulator ) ;
74
86
} else {
75
- tailDeviceLogs ( bootedAndAvailableSimulators [ 0 ] . udid ) ;
87
+ tailDeviceLogs ( bootedAndAvailableSimulators [ 0 ] ) ;
76
88
}
77
89
} ;
78
90
79
- function tailDeviceLogs ( udid : string ) {
91
+ function tailDeviceLogs ( device : Device ) {
80
92
const logDir = path . join (
81
93
os . homedir ( ) ,
82
94
'Library' ,
83
95
'Logs' ,
84
96
'CoreSimulator' ,
85
- udid ,
97
+ device . udid ,
86
98
'asl' ,
87
99
) ;
88
100
101
+ logger . info ( `Tailing logs for device ${ device . name } (${ device . udid } )` ) ;
102
+
89
103
const log = spawnSync ( 'syslog' , [ '-w' , '-F' , 'std' , '-d' , logDir ] , {
90
104
stdio : 'inherit' ,
91
105
} ) ;
0 commit comments