diff --git a/bin/Rakefile b/bin/Rakefile index 97aa0e98..bcea9858 100644 --- a/bin/Rakefile +++ b/bin/Rakefile @@ -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 diff --git a/bin/sim.m b/bin/sim.m index de3b66d3..95552987 100644 --- a/bin/sim.m +++ b/bin/sim.m @@ -1,4 +1,5 @@ #import +#import #import #import @@ -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