[sim] Honour explicit device_name or target specified by user.

Specifying both is disallowed, because a device is configured for a specific SDK.

Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-657
This commit is contained in:
Eloy Durán
2014-11-07 19:22:29 +01:00
parent 17f0da25f6
commit 33effd9154
3 changed files with 21 additions and 5 deletions

3
NEWS
View File

@@ -1,5 +1,8 @@
= RubyMotion 2.39 =
* [iOS] Honour explicit `device_name` or `target` specified by user.
Specifying both is disallowed, because a device is configured for a
specific SDK.
* [iOS] Fixed a regression where Extension and Frameworks could not build for
iOS device.
* [iOS] Fixed a bug where `rake spec' would return 0 as exit code even if it

View File

@@ -1459,13 +1459,23 @@ main(int argc, char **argv)
id sim_runtime = ((id (*)(id, SEL, id))objc_msgSend)(system_root, @selector(runtime), nil);
sim_device = [sim_devices objectAtIndex:0];
// If either `target` or `device_name` was explicitly specified, then
// only compare that specific value and not the other or both.
BOOL specific_sdk = getenv("target") != NULL;
BOOL specific_device = getenv("device_name") != NULL;
BOOL no_specifics = !specific_sdk && !specific_device;
for (id device in sim_devices) {
id device_runtime = ((id (*)(id, SEL, id))objc_msgSend)(device, @selector(runtime), nil);
if (device_runtime == sim_runtime &&
[device_name compare:[device name]] == NSOrderedSame) {
sim_device = device;
break;
if ((specific_device || no_specifics) && [device_name compare:[device name]] != NSOrderedSame) {
continue;
}
if (specific_sdk || no_specifics) {
id device_runtime = ((id (*)(id, SEL, id))objc_msgSend)(device, @selector(runtime), nil);
if (device_runtime != sim_runtime) {
continue;
}
}
sim_device = device;
break;
}
}

View File

@@ -85,6 +85,9 @@ task :simulator do
App.fail "It is not possible to simulate an SDK version (#{target}) " \
"lower than the app's deployment target (#{deployment_target})"
end
if target && ENV['device_name']
App.fail "It is not possible to specify both `device_name' and `target'"
end
target ||= App.config.sdk_version
# May be overridden on Xcode <= 5 with the `device_family' option (see below)