Re: Launching another app with command line arguments
Re: Launching another app with command line arguments
- Subject: Re: Launching another app with command line arguments
- From: Marco S Hyman via Cocoa-dev <email@hidden>
- Date: Sat, 20 Jun 2020 17:04:12 -0700
> On Jun 20, 2020, at 4:31 PM, Gabriel Zachmann <email@hidden> wrote:
>
>>
>> If app B can be treated as a sub-process of app A you can use Process. I
>> know that argument passing works with Process.
>
> Sounds good. How can A launch B as its sub-process? (and pass command line
> arguments?)
>
>
let process = Process()
process.standardOutput = FileHandle.nullDevice
process.standardError = FileHandle.nullDevice
process.launchPath = url.path // path to app
process.arguments = [“arg1”, “arg2”, “arg3”]
process.launch()
and if you need to
process.waitUntilExit()
Obviously don’t wait on the main thread!
I do this in an app where the URL points to a helper located in the bundle.
Not sure what extra hoops you’d need to jump through to launch an app outside
of the sandbox. Probably needs user approval which can be remembered using a
security scoped bookmark.
_______________________________________________
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