Launching another app with command line arguments
Launching another app with command line arguments
- Subject: Launching another app with command line arguments
- From: Gabriel Zachmann via Cocoa-dev <email@hidden>
- Date: Sat, 20 Jun 2020 23:43:38 +0200
I would like to launch app B (developed by me) from app A (also developed by
me).
In app A, I do
let configuration = NSWorkspace.OpenConfiguration()
configuration.activates = true
configuration.arguments = ["-f"]
NSWorkspace.shared.openApplication( at: url_for_app_B_!,
configuration: configuration,
completionHandler: nil )
That works fine, *except* the command line arguments are not passed along :-(
In app B, I do
- (void) applicationWillFinishLaunching: (NSNotification *) notification
{
NSArray * arguments = [[NSProcessInfo processInfo] arguments];
logMessage( log_client_, [arguments componentsJoinedByString:@" "], NO );
...
And, sure enough, in the log I see
/tmp/Debug/B_App.app/Contents/MacOS/B_App
but nothing more.
However, when I do
open -a B_App --args -f
in a Terminal, the arguments are passed into B, and in the log I get
/tmp/Debug/B_App.app/Contents/MacOS/B_App -f
just as expected.
Does anyone have experience with the configuration.arguments property and
NSWorkspace.shared.openApplication?
Could some kind soul please shed some light on this ?
Thanks a lot in advance.
Gabriel.
PS:
Of course, I have already googled and read the docs, to no avail.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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