Browse files

added support for specifying a specific iphone version

  • Loading branch information...
1 parent 0507035 commit 27812bb4bc58a6b8a11579538be13a7f054c9e9b @jhaynie committed Jun 6, 2009
Showing with 25 additions and 4 deletions.
  1. +1 −0 Source/iPhoneSimulator.h
  2. +24 −4 Source/iPhoneSimulator.m
View
1 Source/iPhoneSimulator.h
@@ -35,6 +35,7 @@
@interface iPhoneSimulator : NSObject <DTiPhoneSimulatorSessionDelegate> {
@private
+ DTiPhoneSimulatorSystemRoot *sdkRoot;
}
- (void) runWithArgc: (int) argc argv: (char **) argv;
View
28 Source/iPhoneSimulator.m
@@ -46,7 +46,7 @@ - (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 <application path> [sdkversion]\n");
}
@@ -89,7 +89,6 @@ - (void) session: (DTiPhoneSimulatorSession *) session didStart: (BOOL) started
*/
- (int) launchApp: (NSString *) path {
DTiPhoneSimulatorApplicationSpecifier *appSpec;
- DTiPhoneSimulatorSystemRoot *sdkRoot;
DTiPhoneSimulatorSessionConfig *config;
DTiPhoneSimulatorSession *session;
NSError *error;
@@ -103,7 +102,7 @@ - (int) launchApp: (NSString *) path {
nsprintf(@"App Spec: %@\n", appSpec);
/* Load the default SDK root */
- sdkRoot = [DTiPhoneSimulatorSystemRoot defaultRoot];
+
nsprintf(@"SDK Root: %@\n", sdkRoot);
/* Set up the session configuration */
@@ -122,7 +121,7 @@ - (int) launchApp: (NSString *) path {
[session setDelegate: self];
[session setSimulatedApplicationPID: [NSNumber numberWithInt: 35]];
- if (![session requestStartWithConfig: config timeout: 10 error: &error]) {
+ if (![session requestStartWithConfig: config timeout: 30 error: &error]) {
nsprintf(@"Could not start simulator session: %@", error);
return EXIT_FAILURE;
}
@@ -151,6 +150,27 @@ - (void) runWithArgc: (int) argc argv: (char **) argv {
[self printUsage];
exit(EXIT_FAILURE);
}
+ if (argc > 3) {
+ NSString* ver = [NSString stringWithCString:argv[3]];
+ NSArray *roots = [DTiPhoneSimulatorSystemRoot knownRoots];
+ for (DTiPhoneSimulatorSystemRoot *root in roots) {
+ NSString *v = [root sdkVersion];
+ if ([v isEqualToString:ver])
+ {
+ sdkRoot = root;
+ break;
+ }
+ }
+ if (sdkRoot == nil)
+ {
+ fprintf(stderr,"Unknown or unsupported SDK version: %s\n",argv[3]);
+ [self showSDKs];
+ exit(EXIT_FAILURE);
+ }
+ }
+ else {
+ sdkRoot = [DTiPhoneSimulatorSystemRoot defaultRoot];
+ }
/* Don't exit, adds to runloop */
[self launchApp: [NSString stringWithUTF8String: argv[2]]];

0 comments on commit 27812bb

Please sign in to comment.