mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-05-18 03:53:50 +08:00
fix race condition when launching simulator and activating simulator (in the foreground)
This commit is contained in:
@@ -27,7 +27,7 @@ task :sim do
|
||||
bin = File.join(template, 'sim')
|
||||
if !File.exist?(bin) or File.mtime('sim.m') > File.mtime(bin) or File.mtime('builtin_debugger_cmds.h') > File.mtime(bin)
|
||||
define = "-DSIMULATOR_#{template.upcase}"
|
||||
sh "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang #{define} -mmacosx-version-min=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -I./src -std=c99 -Wall -O3 sim.m -o \"#{bin}\" -framework Foundation -framework ApplicationServices -L. -ledit -Wl,-rpath,/usr/lib -I."
|
||||
sh "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang #{define} -mmacosx-version-min=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -I./src -std=c99 -Wall -O3 sim.m -o \"#{bin}\" -framework Foundation -framework ApplicationServices -framework AppKit -L. -ledit -Wl,-rpath,/usr/lib -I."
|
||||
sh "#{STRIP} -x \"#{bin}\""
|
||||
end
|
||||
end
|
||||
|
||||
16
bin/sim.m
16
bin/sim.m
@@ -1,4 +1,5 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#import <objc/message.h>
|
||||
@@ -954,6 +955,16 @@ gdb_commands_file(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Open simulator to the foreground.
|
||||
if (!spec_mode) {
|
||||
NSArray *ary = [NSRunningApplication runningApplicationsWithBundleIdentifier:
|
||||
@"com.apple.iphonesimulator"];
|
||||
if (ary != nil && [ary count] == 1) {
|
||||
[[ary objectAtIndex:0] activateWithOptions:
|
||||
NSApplicationActivateIgnoringOtherApps];
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_mode == DEBUG_GDB) {
|
||||
NSNumber *pidNumber = ((id (*)(id, SEL))objc_msgSend)(session,
|
||||
@selector(simulatedApplicationPID));
|
||||
@@ -1204,11 +1215,6 @@ main(int argc, char **argv)
|
||||
signal(SIGPIPE, sigcleanup);
|
||||
}
|
||||
|
||||
// Open simulator to the foreground.
|
||||
if (!spec_mode) {
|
||||
system("/usr/bin/open -a \"iPhone Simulator\"");
|
||||
}
|
||||
|
||||
[[NSRunLoop mainRunLoop] run];
|
||||
|
||||
#else // !SIMULATOR_IOS
|
||||
|
||||
Reference in New Issue
Block a user