+void make_foreground_app(NSApplication *app)
+{
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+ // This makes windows appear when run from terminal
+ if([app respondsToSelector:@selector(setActivationPolicy:)])
+ {
+ [app setActivationPolicy:NSApplicationActivationPolicyRegular];
+ return;
+ }
+#else
+ (void)app;
+#endif
+
+ ProcessSerialNumber psn = { 0, kCurrentProcess };
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+ SetFrontProcess(&psn);
+}
+