Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch OS X Application Programmatically

How do I programmatically open an OS X app (.app) that is contained within the app I am building?


1 Answers

The preferred way of doing this on OS X is through the NSWorkspace class, which provides a couple of methods to launch applications. One of them, launchApplicationAtURL:options:configuration:error: allows you to specify a file URL to the application to launch. In addition of not having sandbox problems like the system() and Apple Event solution, it also gives you an easy way to manipulate how the application should be launched, eg. you can specify environment variables to be passed to the application.

like image 187
JustSid Avatar answered Aug 22 '26 12:08

JustSid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!