Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for selecting the SDK version, and add getopt_long options.

  • Loading branch information...
commit 8cf8e6d1ecc3a465177e4229e5632c23b7e965e7 1 parent 505dc4c
@landonf authored
View
38 Source/iPhoneSimExample.m
@@ -27,7 +27,7 @@
#import "iPhoneSimExample.h"
#import "nsprintf.h"
-
+#import <getopt.h>
/**
* A simple usage example for the iPhoneSimulatorRemoteClient
@@ -42,8 +42,10 @@ - (void) printUsage {
fprintf(stderr, "Usage: iphonesim <options> <command> ...\n");
fprintf(stderr, "Commands:\n");
fprintf(stderr, " showsdks\n");
- fprintf(stderr, " launch [-d device family] <application path>\n");
- fprintf(stderr, " Supported device families: iPhone iPad\n");
+ fprintf(stderr, " launch [options] <application path>\n");
+ fprintf(stderr, " Options:\n");
+ fprintf(stderr, " -d/--device-family [family]\tSupported device families: iPhone iPad\n");
+ fprintf(stderr, " -s/--sdk-version [version]\tThe SDK version (eg, 3.0, 3.1, 3.2)\n");
}
@@ -84,7 +86,7 @@ - (void) session: (DTiPhoneSimulatorSession *) session didStart: (BOOL) started
/**
* Launch the given Simulator binary.
*/
-- (int) launchApp: (NSString *) path simulatedDeviceFamily: (NSNumber *) simulatedDeviceFamily {
+- (int) launchApp: (NSString *) path sdkVersion: (NSString *) version simulatedDeviceFamily: (NSNumber *) simulatedDeviceFamily {
DTiPhoneSimulatorApplicationSpecifier *appSpec;
DTiPhoneSimulatorSystemRoot *sdkRoot;
DTiPhoneSimulatorSessionConfig *config;
@@ -99,8 +101,17 @@ - (int) launchApp: (NSString *) path simulatedDeviceFamily: (NSNumber *) simulat
}
nsprintf(@"App Spec: %@\n", appSpec);
- /* Load the default SDK root */
- sdkRoot = [DTiPhoneSimulatorSystemRoot defaultRoot];
+ /* Load the SDK root */
+ if (version != nil) {
+ sdkRoot = [DTiPhoneSimulatorSystemRoot rootWithSDKVersion: version];
+ if (sdkRoot == nil) {
+ nsprintf(@"Can't find SDK for version %@", version);
+ return EXIT_FAILURE;
+ }
+ } else {
+ sdkRoot = [DTiPhoneSimulatorSystemRoot defaultRoot];
+ }
+
nsprintf(@"SDK Root: %@\n", sdkRoot);
/* Set up the session configuration */
@@ -152,12 +163,23 @@ - (void) runWithArgc: (int) argc argv: (char **) argv {
}
/* Parse any arguments */
+ NSString *sdkVersion = nil;
NSNumber *simulatedDeviceFamily = nil;
int ch;
argc -= 1;
argv += 1;
- while ((ch = getopt(argc, argv, "d:")) != -1) {
+
+ static struct option longopts[] = {
+ { "device-family", required_argument, NULL, 'd' },
+ { "sdk-version", required_argument, NULL, 's' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ while ((ch = getopt_long(argc, argv, "s:d:", longopts, NULL)) != -1) {
switch (ch) {
+ case 's':
+ sdkVersion = [NSString stringWithUTF8String: optarg];
+ break;
case 'd':
if (strcmp(optarg, "iPad") == 0) {
simulatedDeviceFamily = [NSNumber numberWithInt: 2];
@@ -179,7 +201,7 @@ - (void) runWithArgc: (int) argc argv: (char **) argv {
argv += optind;
/* Don't exit, adds to runloop */
- [self launchApp: [NSString stringWithUTF8String: argv[0]] simulatedDeviceFamily: simulatedDeviceFamily];
+ [self launchApp: [NSString stringWithUTF8String: argv[0]] sdkVersion: sdkVersion simulatedDeviceFamily: simulatedDeviceFamily];
} else {
fprintf(stderr, "Unknown command\n");
[self printUsage];
View
5 iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h
@@ -39,8 +39,9 @@
+ (id) defaultRoot;
-+ (id)rootWithSDKPath:(id)fp8;
-+ (id)rootWithSDKVersion:(id)fp8;
++ (id)rootWithSDKPath:(NSString *) path;
++ (id)rootWithSDKVersion:(NSString *)version;
+
+ (NSArray *) knownRoots;
- (id)initWithSDKPath:(id)fp8;
- (id)sdkDisplayName;
Please sign in to comment.
Something went wrong with that request. Please try again.