Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After hell of searching and experimenting I am ready to answer my own question, so others can save their time and efforts.</p> <p>My conclusion is that for now there is no way HelperApp can launch MainApp with some arguments under the Sandbox. At least I have not found any way to do that.</p> <p>Launch MainApp like this:</p> <pre><code>[[NSWorkspace sharedWorkspace] launchApplication:newPath]; </code></pre> <p>In MainApp add the following:</p> <pre><code>Application_IsLaunchedByHelperApp = YES; ProcessSerialNumber currPSN; OSStatus err = GetCurrentProcess(&amp;currPSN); if (!err) { // Get information about our process NSDictionary * currDict = [(NSDictionary *)ProcessInformationCopyDictionary(&amp;currPSN, kProcessDictionaryIncludeAllInformationMask) autorelease]; // Get the PSN of the app that launched us. Its not really the parent app, in the unix sense. long long temp = [[currDict objectForKey:@"ParentPSN"] longLongValue]; long long hi = (temp &gt;&gt; 32) &amp; 0x00000000FFFFFFFFLL; long long lo = (temp &gt;&gt; 0) &amp; 0x00000000FFFFFFFFLL; ProcessSerialNumber parentPSN = {(UInt32)hi, (UInt32)lo}; // Get info on the launching process NSDictionary * parentDict = [(NSDictionary*)ProcessInformationCopyDictionary(&amp;parentPSN, kProcessDictionaryIncludeAllInformationMask) autorelease]; // analyze // parent app info is not null ? if (parentDict &amp;&amp; parentDict.count &gt; 0) { NSString * launchedByAppBundleId = [parentDict objectForKey:@"CFBundleIdentifier"]; if (![launchedByAppBundleId isEqualToString:HELPER_APP_BUNDLE_ID]) { Application_IsLaunchedByHelperApp = NO; } } } </code></pre> <p>That's it. <code>Application_IsLaunchedByHelperApp</code> now has correct value.</p> <p>The solution is not mine. I've found it on the web (cocoabuilder, I guess). Good luck to everyone! And thanks for your attention to my questions.</p> <p><strong>UPDATE</strong> Looks like there are cases when launched at login app shows <code>launchedByAppBundleId = @"com.apple.loginwindow"</code>. So the last part of code will look like this:</p> <pre><code> // // analyze // // parent app info is not null ? if (parentDict &amp;&amp; parentDict.count &gt; 0) { NSString * launchedByAppBundleId = [parentDict objectForKey:@"CFBundleIdentifier"]; if (![launchedByAppBundleId isEqualToString:HELPER_APP_BUNDLE_ID] &amp;&amp; ![launchedByAppBundleId isEqualToString:@"com.apple.loginwindow"]) { Application_IsLaunchedByHelperApp = NO; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload