Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit d20d233

Browse files
committed
[Bug 20670] [Xcode 9+] Detect if a Simulator device is already open
1 parent cf53993 commit d20d233

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

revmobile/src/reviphone.mm

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -604,16 +604,20 @@ bool revIPhoneLaunchAppInSimulator(MCVariableRef *argv, uint32_t argc, MCVariabl
604604
{
605605
NSDictionary *t_dev_plist;
606606
t_dev_plist = [NSDictionary dictionaryWithContentsOfFile: t_dev_plist_path];
607-
if (t_dev_plist != nil)
608-
{
609-
NSNumber *t_state;
610-
t_state = [t_dev_plist objectForKey: @"state"];
611-
if (t_state != nil && [t_state intValue] == 3 && [t_device runtime] == s_simulator_runtime)
612-
{
613-
t_found_device = true;
614-
break;
615-
}
616-
}
607+
if (t_dev_plist != nil)
608+
{
609+
NSNumber *t_state;
610+
t_state = [t_dev_plist objectForKey: @"state"];
611+
// In Xcode 9+ you can run multiple simulator instances. This seems to have broken the check [t_device runtime] == s_simulator_runtime.
612+
// So check for matching identifiers to detect if a simulator device is already up and running
613+
bool t_maching_runtimes = [t_device runtime] == s_simulator_runtime;
614+
bool t_maching_runtime_identifiers = [t_device.runtime.identifier compare: s_simulator_runtime.identifier] == NSOrderedSame;
615+
if (t_state != nil && [t_state intValue] == 3 && (t_maching_runtimes || t_maching_runtime_identifiers))
616+
{
617+
t_found_device = true;
618+
break;
619+
}
620+
}
617621
}
618622
}
619623

0 commit comments

Comments
 (0)