Skip to content
Browse files

Allow selection of the device family.

  • Loading branch information...
1 parent c891bb4 commit 54aaafbd3f5b856910937b09e9e913fde91102e1 @landonf committed Jan 30, 2010
Showing with 40 additions and 6 deletions.
  1. +1 −1 Makefile
  2. +35 −5 Source/iPhoneSimExample.m
  3. +4 −0 iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h
View
2 Makefile
@@ -1,7 +1,7 @@
CC=gcc
SIM_PRIVATE_FRAMEWORK_DIR?=/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks
-CFLAGS=-Wall -Werror -I. -ISource
+CFLAGS=-std=c99 -Wall -Werror -I. -ISource
LDFLAGS=-framework AppKit -F${SIM_PRIVATE_FRAMEWORK_DIR} -framework iPhoneSimulatorRemoteClient -Wl,-rpath -Wl,${SIM_PRIVATE_FRAMEWORK_DIR}
OBJS= \
Source/main.o \
View
40 Source/iPhoneSimExample.m
@@ -42,7 +42,8 @@ - (void) printUsage {
fprintf(stderr, "Usage: iphonesim <options> <command> ...\n");
fprintf(stderr, "Commands:\n");
fprintf(stderr, " showsdks\n");
- fprintf(stderr, " launch <application path>\n");
+ fprintf(stderr, " launch [-d device family] <application path>\n");
+ fprintf(stderr, " Supported device families: iPhone iPad\n");
}
@@ -83,7 +84,7 @@ - (void) session: (DTiPhoneSimulatorSession *) session didStart: (BOOL) started
/**
* Launch the given Simulator binary.
*/
-- (int) launchApp: (NSString *) path {
+- (int) launchApp: (NSString *) path simulatedDeviceFamily: (NSNumber *) simulatedDeviceFamily {
DTiPhoneSimulatorApplicationSpecifier *appSpec;
DTiPhoneSimulatorSystemRoot *sdkRoot;
DTiPhoneSimulatorSessionConfig *config;
@@ -110,6 +111,8 @@ - (int) launchApp: (NSString *) path {
[config setSimulatedApplicationLaunchArgs: [NSArray array]];
[config setSimulatedApplicationLaunchEnvironment: [NSDictionary dictionary]];
+ if (simulatedDeviceFamily != nil && [config respondsToSelector: @selector(setSimulatedDeviceFamily:)])
+ [config setSimulatedDeviceFamily: simulatedDeviceFamily];
[config setLocalizedClientName: @"iPhoneSimExample"];
@@ -141,17 +144,44 @@ - (void) runWithArgc: (int) argc argv: (char **) argv {
exit([self showSDKs]);
}
else if (strcmp(argv[1], "launch") == 0) {
- /* Requires an additional argument */
+ /* Requires at least one additional argument */
if (argc < 3) {
fprintf(stderr, "Missing application path argument\n");
[self printUsage];
exit(EXIT_FAILURE);
}
+ /* Parse any arguments */
+ NSNumber *simulatedDeviceFamily = nil;
+ int ch;
+ argc -= 1;
+ argv += 1;
+ while ((ch = getopt(argc, argv, "d:")) != -1) {
+ switch (ch) {
+ case 'd':
+ if (strcmp(optarg, "iPad") == 0) {
+ simulatedDeviceFamily = [NSNumber numberWithInt: 2];
+ } else if (strcmp(optarg, "iPhone") == 0) {
+ simulatedDeviceFamily = [NSNumber numberWithInt: 1];
+ } else {
+ fprintf(stderr, "Unknown device type: %s\n", optarg);
+ [self printUsage];
+ exit(EXIT_FAILURE);
+ }
+ break;
+ default:
+ fprintf(stderr, "Unknown option %s optarg\n", optarg);
+ [self printUsage];
+ exit(EXIT_FAILURE);
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
/* Don't exit, adds to runloop */
- [self launchApp: [NSString stringWithUTF8String: argv[2]]];
+ [self launchApp: [NSString stringWithUTF8String: argv[0]] simulatedDeviceFamily: simulatedDeviceFamily];
} else {
- fprintf(stderr, "Unknow command\n");
+ fprintf(stderr, "Unknown command\n");
[self printUsage];
exit(EXIT_FAILURE);
}
View
4 iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h
@@ -66,6 +66,8 @@
NSString *_simulatedApplicationStdErrPath;
}
++ (NSString *) displayNameForDeviceFamily: (NSNumber *) family;
+
- (id)simulatedApplicationStdErrPath;
- (void)setSimulatedApplicationStdErrPath:(id)fp8;
- (id)simulatedApplicationStdOutPath;
@@ -80,6 +82,8 @@
- (DTiPhoneSimulatorSystemRoot *) simulatedSystemRoot;
- (void) setSimulatedSystemRoot: (DTiPhoneSimulatorSystemRoot *) simulatedSystemRoot;
+- (NSNumber *) simulatedDeviceFamily;
+- (void) setSimulatedDeviceFamily: (NSNumber *) family;
- (BOOL) simulatedApplicationShouldWaitForDebugger;
- (void) setSimulatedApplicationShouldWaitForDebugger: (BOOL) waitForDebugger;

0 comments on commit 54aaafb

Please sign in to comment.
Something went wrong with that request. Please try again.