2
2
"use strict" ;
3
3
4
4
import options = require( "./options" ) ;
5
+ import utils = require( "./utils" ) ;
5
6
import util = require( "util" ) ;
6
7
8
+ var $ = require ( "NodObjC" ) ;
7
9
8
10
export class XCode5Simulator implements ISimulator {
9
11
10
- private static DEFAULT_DEVICE_IDENTIFIER = "Resizable-iPad " ;
12
+ private static DEFAULT_DEVICE_IDENTIFIER = "iPhone " ;
11
13
12
- private static allowedDeviceIdentifiers = [
13
- "iPhone" ,
14
- "iPhone Retina (3.5-inch)" ,
15
- "iPhone Retina (4-inch)" ,
16
- "iPhone Retina (4-inch 64-bit)" ,
17
- "iPad" ,
18
- "iPad Retina" ,
19
- "iPad Retina (64-bit)"
20
- ] ;
14
+ private static allowedDeviceIdentifiers : IDictionary < string > = {
15
+ "iPhone" : "iPhone" ,
16
+ "iPhone-Retina-3.5-inch" : "iPhone Retina (3.5-inch)",
17
+ "iPhone-Retina-4-inch" : "iPhone Retina (4-inch)",
18
+ "iPhone-Retina-4-inch-64-bit" : "iPhone Retina (4-inch 64-bit)",
19
+ "iPad" : "iPad" ,
20
+ "iPad-Retina" : "iPad Retina",
21
+ "iPad-Retina-64-bit" : "iPad Retina (64-bit)"
22
+ }
21
23
22
24
public validateDeviceIdentifier ( ) : void {
25
+ var identifiers : string [ ] = _ . keys ( XCode5Simulator . allowedDeviceIdentifiers ) ;
26
+ if ( ! _ . contains ( identifiers , options . device ) ) {
27
+ throw new Error ( util . format ( "Invalid device identifier %s. Valid device identifiers are %s." , options . device , utils . stringify ( identifiers ) ) ) ;
28
+ }
23
29
}
24
30
25
31
public setSimulatedDevice ( config :any ) : void {
26
- config ( "setSimulatedDeviceInfoName" , this . deviceIdentifier ) ;
32
+ config ( "setSimulatedDeviceInfoName" , $ ( this . deviceIdentifier ) ) ;
27
33
}
28
34
29
- private get deviceIdentifier ( ) {
30
- return options . devie || XCode5Simulator . DEFAULT_DEVICE_IDENTIFIER ;
35
+ private get deviceIdentifier ( ) : string {
36
+ var identifier = options . device || XCode5Simulator . DEFAULT_DEVICE_IDENTIFIER ;
37
+ return XCode5Simulator . allowedDeviceIdentifiers [ identifier ] ;
31
38
}
32
39
}
0 commit comments