@@ -190,7 +190,7 @@ - (int) showDeviceTypes {
190
190
SimDeviceSet* deviceSet = [simDeviceSet defaultSet ];
191
191
NSArray * devices = [deviceSet availableDevices ];
192
192
for (SimDevice* device in devices) {
193
- nsfprintf (stderr, @" %@ " , device.deviceType .identifier );
193
+ nsfprintf (stderr, @" %@ , %@ " , device.deviceType .identifier , device. runtime . versionString );
194
194
}
195
195
}
196
196
@@ -459,12 +459,25 @@ - (SimDevice*) findDeviceWithFamily:(NSString *)family retina:(BOOL)retina isTal
459
459
460
460
SimDeviceSet* deviceSet = [[self FindClassByName: @" SimDeviceSet" ] defaultSet ];
461
461
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
+ }
468
481
// Default to whatever is the first device
469
482
return [devices count ] > 0 ? [devices objectAtIndex: 0 ] : nil ;
470
483
}
0 commit comments