@@ -4,25 +4,14 @@ import errors = require("./errors");
4
4
import options = require( "./options" ) ;
5
5
import utils = require( "./utils" ) ;
6
6
import util = require( "util" ) ;
7
+ import os = require( "os" ) ;
7
8
var $ = require ( "NodObjC" ) ;
8
9
9
10
export class XCode6Simulator implements ISimulator {
10
11
11
12
private static DEVICE_IDENTIFIER_PREFIX = "com.apple.CoreSimulator.SimDeviceType" ;
12
13
private static DEFAULT_DEVICE_IDENTIFIER = "iPhone-4s" ;
13
14
14
- private static allowedDeviceIdentifiers = [
15
- "iPhone-4s" ,
16
- "iPhone-5" ,
17
- "iPhone-5s" ,
18
- "iPhone-6" ,
19
- "iPhone-6-Plus" ,
20
- "Resizable-iPhone" ,
21
- "iPad-2" ,
22
- "iPad-Retina" ,
23
- "iPad-Air" ,
24
- "Resizable-iPad"
25
- ] ;
26
15
27
16
private availableDevices : IDictionary < IDevice > ;
28
17
@@ -31,7 +20,29 @@ export class XCode6Simulator implements ISimulator {
31
20
}
32
21
33
22
public get validDeviceIdentifiers ( ) : string [ ] {
34
- return XCode6Simulator . allowedDeviceIdentifiers ;
23
+ var simDeviceSet = $ . classDefinition . getClassByName ( "SimDeviceSet" ) ;
24
+ var devicesInfo : string [ ] = [ ] ;
25
+
26
+ if ( simDeviceSet ) {
27
+ var deviceSet = simDeviceSet ( "defaultSet" ) ;
28
+ var devices = deviceSet ( "availableDevices" ) ;
29
+
30
+ var count = devices ( "count" ) ;
31
+ for ( var index = 0 ; index < count ; index ++ ) {
32
+ var device = devices ( "objectAtIndex" , index ) ;
33
+
34
+ var deviceIdentifier = device ( "deviceType" ) ( "identifier" ) . toString ( ) ;
35
+ var deviceIdentifierPrefixIndex = deviceIdentifier . indexOf ( XCode6Simulator . DEFAULT_DEVICE_IDENTIFIER ) ;
36
+ var deviceIdentifierWithoutPrefix = deviceIdentifier . substring ( deviceIdentifierPrefixIndex + XCode6Simulator . DEVICE_IDENTIFIER_PREFIX . length + 2 ) ;
37
+
38
+ var runtimeVersion = device ( "runtime" ) ( "versionString" ) . toString ( ) ;
39
+ var deviceInfo = [ util . format ( "Device Identifier: %s" , deviceIdentifierWithoutPrefix ) ,
40
+ util . format ( "Runtime Version: %s" , runtimeVersion ) ] . join ( os . EOL ) ;
41
+ devicesInfo . push ( deviceInfo + os . EOL ) ;
42
+ }
43
+ }
44
+
45
+ return devicesInfo ;
35
46
}
36
47
37
48
public setSimulatedDevice ( config : any ) : void {
0 commit comments