Skip to content

Commit ae1b289

Browse files
Daniel Prowsshazron
authored andcommitted
Fixes #97 - Xcode 6 support for specifying the os version of the simulator
Signed-off-by: Shazron Abdullah <[email protected]>
1 parent aa583e9 commit ae1b289

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

Source/iPhoneSimulator.m

100644100755
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ - (int) showDeviceTypes {
190190
SimDeviceSet* deviceSet = [simDeviceSet defaultSet];
191191
NSArray* devices = [deviceSet availableDevices];
192192
for (SimDevice* device in devices) {
193-
nsfprintf(stderr, @"%@", device.deviceType.identifier);
193+
nsfprintf(stderr, @"%@, %@", device.deviceType.identifier, device.runtime.versionString);
194194
}
195195
}
196196

@@ -459,12 +459,25 @@ - (SimDevice*) findDeviceWithFamily:(NSString *)family retina:(BOOL)retina isTal
459459

460460
SimDeviceSet* deviceSet = [[self FindClassByName:@"SimDeviceSet"] defaultSet];
461461
NSArray* devices = [deviceSet availableDevices];
462-
for (SimDevice* device in devices) {
463-
SimDeviceType* type = device.deviceType;
464-
if ([type.identifier isEqualToString:devTypeId]) {
465-
return device;
466-
}
467-
}
462+
NSArray* deviceTypeAndVersion = [devTypeId componentsSeparatedByString:@","];
463+
if(deviceTypeAndVersion.count == 2) {
464+
NSString* typeIdentifier = [deviceTypeAndVersion.firstObject stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
465+
NSString* versionString = [deviceTypeAndVersion.lastObject stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];;
466+
for (SimDevice* device in devices) {
467+
if ([device.deviceType.identifier isEqualToString:typeIdentifier] && [device.runtime.versionString isEqualToString:versionString]) {
468+
return device;
469+
}
470+
}
471+
}
472+
//maintain old behavior (if the device identifier doesn't have a version as part of the identifier, loop through to find the first matching)
473+
else
474+
{
475+
for (SimDevice* device in devices) {
476+
if ([device.deviceType.identifier isEqualToString:devTypeId]) {
477+
return device;
478+
}
479+
}
480+
}
468481
// Default to whatever is the first device
469482
return [devices count] > 0 ? [devices objectAtIndex:0] : nil;
470483
}

0 commit comments

Comments
 (0)