I'm developing a C application for OSX with gcc.
When I launch my application with double click in finder a terminal window is shown. My application only does some basic operations and exits. Is there a way to prevent the terminal window from showing up?
In win32 I can set the subsystem to WINDOWS in PE executable. Is there something analogous for OSX?
Thanks in advance.
Related
According to this release note, there is a new #![windows_subsystem(windows)] attribute that does not display a console when running a windowed application. It works on Windows and everything is fine.
I don't know what to do to make it work for macOS too. When I launch my app on macOS, it displays a console. Is there a way to hide the console even for a Mac application?
Cargo builds Unix-style executable.
In order to not open the terminal on launch, you have to create an OSX application wrapper, a.k.a bundle. You could use cargo-bundle for this need.
I have created a small Cocoa application and built a Mach-O file using cross-platform tools. It is working Ok.
If I bring the Mach-O file to Mac (MacBook Pro OSX 10.11) it appears with Terminal icon in the Finder. If I double-click it, it opens unix Terminal window and starts the application from within the Terminal. Once my app starts, it opens its own window and works as expected. Of course, the Terminal window besides the application looks ugly. How do I make it start without opening the Terminal window?
My guess there should be some flag in Mach-O file to indicate it's a GUI application and doesn't need a Terminal, but I haven't found anything like that.
How does being inside an application bundle affect how the binary executable runs?
To explain, I compiled Emacs for Mountain Lion. This produces a binary executable, and also an application bundle, Emacs.app, that contains the exact same binary (same content, according to diff), plus other resources.
If I run the binary itself from the terminal (or finder):
Emacs starts, processes my init file correctly and looks good.
But the application menu still says "Terminal" and
keyboard input goes to the terminal not to Emacs.
Also the red traffic-light button gets sent to Emacs (Emacs says it has nothing to save) but does not terminate the process.
In contrast, if I run the Emacs.app, Emacs runs as expected. Can anyone explain this difference for me please?
When you launch an .app bundle, the Info.plist at the root of the folder configures many OS specific behaviors.
https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html
You can launch any native executable this way and have the same behavior.
I've got a Flash projector which I plan to distribute on CD. I'm making a projector for Mac and Windows. I know how to do Autorun on Windows, but I want to do so on Mac as well.
How does that work?
It doesn't. Mac OS 7–9 had a similar system but Mac OS X has nothing of the sort.
Your best bet is to make a nice Finder window design that makes it clear what to do. DropDMG may be useful.
There is no autorun in OSX anymore.
You can't set an application to autorun for security reasons. However you can set a Finder window to auto open on insert. I've seen a lot of CDs do this then have a "Click here to start" icon.
This is the terminal command to set it up on your diskimage before burning. discName should be the name of your disk image.
sudo bless -folder "/Volumes/discName" -openfolder "/Volumes/discName"
More info here
There is an easy way to do it. Just right-click the icon in the dock, chose "Options", then "Open at Login"
Then the selected app will launch every time OSX boots.
I have a Mono application that should not show on the dock, but will occasionally show a window. I want neither menu bar nor dock icon to show for this application. I have my application wrapped in an app bundle, and my info.plist file has the LSUIElement set to "1". This does not seem to be hiding my application from the Dock.
I have tried also calling osascript with the following info in a Process.Start:
osascript -e 'tell application "System Events" to set visible of process "myapp" to false'
This returns a System Event error code: -10006. Thus far, I've had no luck finding out what that means.
I've also tried all the standard Hide() and Visibility = false stuff inside Mono.
Anyone found a workaround for this, or have an idea a direction I can look in? For the most part, working in Mono has been straightforward .Net coding, but this has me stumped.
Well, after a fair amount of work, I figured out a better way to do this. I am generating a Silverlight + mono application targeting OSX. I needed to get both launching from the same button press.
Solved it with a bash script command from within the bundle that the Silverlight OOB installation process creates, and simply distributed the created bundle, with some rsync commands.
The line that launches the server bit (created using Mono's macpack tool):
open MyApp.app &
The line that then launches the Silverlight OOB app normally:
./Silverlight $# &> /dev/null
The '$#' bit passes all the initial arguments into the Silverlight executable in the OOB app. Means you have to play with the Info.plist to make it launch your own launcher, so your 'Silverlight' executable doesn't get overwritten on a Silverlight update, but seems to work quite well.
This is what you are looking for: http://uselessthingies.wordpress.com/2008/05/18/an-app-without-dock-icon-and-menu-bar/
tl;dr: Package your .app, and in your app's Info.plist add <key>LSUIElement</key><string>1</string>.