Re: Starting Cocoa apps from the command line
Re: Starting Cocoa apps from the command line
- Subject: Re: Starting Cocoa apps from the command line
- From: Eric Schlegel <email@hidden>
- Date: Thu, 11 Dec 2008 10:18:55 -0800
Jumping in late here...
It sounds like what you want to create is just a flat-file binary that
does not use the bundle hierarchy that is typical for a Mac OS X app.
I.e., you want your app to just be a single file "MyApp" rather than a
hierarchy "MyApp.app/Contents/MacOS/MyApp". Is that correct?
If so, then the problem is that the process management system on Mac
OS X, by default, only makes bundled applications capable of receiving
keyboard focus. By default, unbundled applications are not capable of
receiving keyboard focus. Normally, this is what you want; if you run
gcc, you don't want the gcc process to become the foreground app.
However, once your app is launched, you can enable it to receive
keyboard focus and become the frontmost app by calling the
TransformProcessType API in the CoreServices Process Manager header:
#include <CoreServices/CoreServices.h>
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType( &psn, kProcessTransformToForegroundApplication );
-eric
On Dec 11, 2008, at 10:07 AM, Shayne Wissler wrote:
Thanks for all the varied answers! It sounds like no one actually
knows architecturally what is going on here or why! Is there perhaps
some "dissonance" between the UNIX design aspects and the Apple design
aspects of OSX?
But it sounds like I can hack my way through given your suggestions,
thanks again.
Shayne Wissler
On Wed, Dec 10, 2008 at 2:47 PM, Shayne Wissler <email@hidden>
wrote:
Hello,
I have a Cocoa application that I am compiling in the traditional
UNIX
manner using Makefiles and I want to be able to invoke it with
command-line arguments and without creating/installing it like
traditional OSX apps, as in "x.app/Contents/MacOS/x". When I tried
the
usual thing that works on UNIX, compiling to binary and just running
it, my application got mouse events but no keyboard events, among
other strange things.
Is there a way to do this without making some kind of wrapper caller
that generates the directory and a script or some such? Or is it
wholly frowned upon to do what I'm wanting, and if so, why does it
half-work rather than fail with a decent error message?
Shayne Wissler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden