On Oct 15, 2013, at 10:48 AM, Jens Alfke <j...@mooseyard.com> wrote:

> 
> On Oct 15, 2013, at 4:12 AM, Bill Cheeseman <wjcheese...@gmail.com> wrote:
> 
>> Is there any way to test whether an application is running in Xcode or some 
>> other compiler/debugger, and not as a free-standing application? And then to 
>> get the name of the compiler/debugger?
> 
> Just curious: What is it you want to do with that information?
> 
> Keep in mind that technically there is no such thing as a ‘free-standing 
> application’. Every user process has a parent. When you launch an app through 
> ‘normal’ means, like from the Finder or Dock, its parent will be the launchd 
> process that owns your login session. It’s also possible for an app’s parent 
> process to be a tool like Instruments that isn’t technically a debugger. Or 
> you could launch the app from a shell in which case its parent process is 
> that shell.


Jens, 

I can't talk about the "why?" part of my question in public because it's an 
issue unique to Mavericks. Let me just say that a certain common category of 
applications is going to want to know how to do this in Mavericks, for good and 
sufficient reason.

But the "is it running in Xcode (or Instruments or whatever)?" question is not 
unique to Mavericks. What I find interesting is that NSWorkspace's 
-frontmostApplication and -menuBarOwningApplication and NSRunningApplication's 
currentApplication return different results in different circumstances. For 
example, when I launch an application I'm developing in debug mode in Xcode, 
two of these methods return my application and one of them returns Xcode. If I 
then call [NSApp activateIgnoringOtherApps:] and call these methods again, the 
mix changes -- they all return my application. I can't find a way to get my 
application back into the mode (?) it was in at launch so as to ensure that one 
of the methods consistently returns Xcode. My guess is that the fact that one 
of them returns Xcode at launch is a bug that nobody has noticed, and I 
therefore shouldn't rely on it anyway (otherwise, I would grab it and save it 
at launch time).

So I need a reliable way to find out. I know there is a way, because a certain 
function that is new in Mavericks does it behind the scenes and reports the 
result in a system alert, where the question whether it is running in Xcode (or 
whatever) is crucial. But I can't get the result using that function -- at 
least not in a straightforward way.

Bill

-- 

Bill Cheeseman

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to