1111#import < sys/types.h>
1212#import < sys/stat.h>
1313
14+ NSString *simulatorPrefrencesName = @" com.apple.iphonesimulator" ;
15+ NSString *deviceProperty = @" SimulateDevice" ;
16+ NSString *deviceIphoneRetina = @" iPhone (Retina 3.5-inch)" ;
17+ NSString *deviceIphone = @" iPhone" ;
18+ NSString *deviceIpad = @" iPad" ;
19+ NSString *deviceIpadRetina = @" iPad (Retina)" ;
20+
1421/* *
1522 * A simple iPhoneSimulatorRemoteClient framework.
1623 */
@@ -30,6 +37,7 @@ - (void) printUsage {
3037 fprintf (stderr, " --exit Exit after startup\n " );
3138 fprintf (stderr, " --sdk <sdkversion> The iOS SDK version to run the application on (defaults to the latest)\n " );
3239 fprintf (stderr, " --family <device family> The device type that should be simulated (defaults to `iphone')\n " );
40+ fprintf (stderr, " --retina Start a retina device\n " );
3341 fprintf (stderr, " --uuid <uuid> A UUID identifying the session (is that correct?)\n " );
3442 fprintf (stderr, " --env <environment file path> A plist file containing environment key-value pairs that should be set\n " );
3543 fprintf (stderr, " --setenv NAME=VALUE Set an environment variable\n " );
@@ -210,6 +218,8 @@ - (int)launchApp:(NSString *)path withFamily:(NSString *)family
210218 [config setSimulatedDeviceFamily: [NSNumber numberWithInt: 1 ]];
211219 }
212220 }
221+
222+ [self changeDeviceType: family retina: retinaDevice];
213223
214224 /* Start the session */
215225 session = [[[DTiPhoneSimulatorSession alloc ] init ] autorelease ];
@@ -227,6 +237,29 @@ - (int)launchApp:(NSString *)path withFamily:(NSString *)family
227237 return EXIT_SUCCESS;
228238}
229239
240+ - (void ) changeDeviceType : (NSString *)family retina : (BOOL )retina {
241+ NSString *devicePropertyValue;
242+ if (retina) {
243+ if (verbose) {
244+ nsprintf (@" using retina" );
245+ }
246+ if ([family isEqualToString: @" ipad" ]) {
247+ devicePropertyValue = deviceIpadRetina;
248+ }
249+ else {
250+ devicePropertyValue = deviceIphoneRetina;
251+ }
252+ } else {
253+ if ([family isEqualToString: @" ipad" ]) {
254+ devicePropertyValue = deviceIpad;
255+ } else {
256+ devicePropertyValue = deviceIphone;
257+ }
258+ }
259+ CFPreferencesSetAppValue ((CFStringRef)deviceProperty, (CFPropertyListRef)devicePropertyValue, (CFStringRef)simulatorPrefrencesName);
260+ CFPreferencesAppSynchronize ((CFStringRef)simulatorPrefrencesName);
261+ }
262+
230263
231264/* *
232265 * Execute 'main'
@@ -237,6 +270,7 @@ - (void)runWithArgc:(int)argc argv:(char **)argv {
237270 exit (EXIT_FAILURE);
238271 }
239272
273+ retinaDevice = NO ;
240274 exitOnStartup = NO ;
241275 alreadyPrintedData = NO ;
242276
@@ -311,6 +345,9 @@ - (void)runWithArgc:(int)argc argv:(char **)argv {
311345 i++;
312346 stderrPath = [[NSString stringWithUTF8String: argv[i]] expandPath ];
313347 NSLog (@" stderrPath: %@ " , stderrPath);
348+ } else if (strcmp (argv[i], " --retina" ) == 0 ) {
349+ retinaDevice = YES ;
350+ i++;
314351 } else if (strcmp (argv[i], " --args" ) == 0 ) {
315352 i++;
316353 break ;
0 commit comments