0

According to this page, the function LSOpenApplication has been deprecated since OS X v10.10. The proposed alternative is to use -[NSWorkSpace launchApplicationAtURL] instead. Unfortunately, I'm writing a user agent in C++ that has to launch a GUI application written in Cocoa. This means that I do not have access to Cocoa functions (including the aforementioned alternative).

What other function could I use to help me do this that is not marked as deprecated?

Thanks in advance.

Michiel Boekhoff
  • 221
  • 3
  • 13

1 Answers1

1

You can open an application using LSOpenCFURLRef() with the URL of the application you want to open. Similarly, you can use LSOpenFromURLSpec() with an LSLaunchURLSpec with the URL of an application in the appURL field.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • 1
    Can I supply arguments to the process like I can with LSOpenApplication? – Michiel Boekhoff Dec 04 '14 at 21:20
  • 1
    Not exactly, but it's uncommon to pass arguments to applications. First, "opening" an application can mean re-opening it. That is, if it's already running, it will be activated and will receive an 'rapp' Apple Event. In that case, it doesn't receive command-line arguments because those are only meaningful at launch. Similarly, one usually communicates to a GUI app through Apple Events. So, for example, if you open a document with an app, it isn't passed as a command-line argument. Instead, it's passed in an 'odoc' Apple Event. `LSOpenFromURLSpec()` will do that for your with the `itemURLs`. – Ken Thomases Dec 04 '14 at 21:43
  • Thanks. I'll try the AppleEvent method! – Michiel Boekhoff Dec 04 '14 at 22:04